爬虫python3:TypeError: cannot use a string pattern on a bytes-like object
import re
from common_p3 import download def crawl_sitemap(url):
sitemap = download(url)
links = re.findall('<loc>(.*?)</loc>',sitemap)
print('links=',links)
for link in links:
print('link=',link)
html = download(link)
return crawl_sitemap('http://example.webscraping.com/sitemap.xml') TypeError: cannot use a string pattern on a bytes-like object (主要是版本问题)
对于python3x
'sitemap = download(url)'应改为‘sitemap = download(url).decode('utf-8')’
爬虫python3:TypeError: cannot use a string pattern on a bytes-like object的更多相关文章
- TypeError: cannot use a string pattern on a bytes-like object的解决办法
#!/usr/python3 import re import urllib.request def gethtml(url): page=urllib.request.urlopen(url) ht ...
- TypeError: cannot use a string pattern on a bytes-like object
一劳永逸解决:TypeError: cannot use a string pattern on a bytes-like object TypeError: cannot use a string ...
- Python3 TypeError: initial_value must be str or None, not bytes
response.read() returns an instance of bytes while StringIO is an in-memory stream for text only. Us ...
- python3 pycurl 出现 TypeError: string argument expected, got 'bytes' 解决方案
用pycurl请求指定链接并返回结果时出现 TypeError: string argument expected, got 'bytes' 错误 经过排查问题出现在使用StringIO的write ...
- Symbols of String Pattern Matching
Symbols of String Pattern Matching in Introduction to Algorithms. As it's important to be clear when ...
- Python 出现 can't use a string pattern on a bytes-like object
Python 出现 can't use a string pattern on a bytes-like object 学习了:https://www.cnblogs.com/andrewleeeee ...
- int preg_match( string pattern
preg_match -- 进行正则表达式匹配.并且只匹配一次,注意与preg_match_all区别. int preg_match( string pattern, string subject ...
- 转 python3中SQLLIT编码与解码之Unicode与bytes
#########sample########## sqlite3.OperationalError: Could not decode to UTF-8 column 'logtype' with ...
- 关于TypeError: strptime() argument 1 must be str, not bytes解析
关于TypeError: strptime() argument 1 must be str, not bytes解析 在使用datetime.strptime(s,fmt)来输出结果日期结果时, ...
随机推荐
- IE11下文档模式默认值是7, 而且无法更改
IE9以上是支持css3的,但是有的IE11的浏览器里面,文档模式默认值是7,而且是无法改变的,就会导致网页布局错乱 我的IE11的文档模式默认值是11 ,如下图 (打开页面按F12) 对于默认值是 ...
- SQL去掉重复数据
SELECT vc_your_email,vc_our_ref_or_code INTO #tmp FROM( SELECT vc_your_email,vc_our_ref_or_code,ROW_ ...
- 在Docker中运行PostgreSQL + pgAdmin 4
拉取postgresql镜像:docker pull postgres 运行postgresql:docker run -d -p 5432:5432 --name postgresql -v pgd ...
- c语音学习笔记
1.学习教程参考了杨光福 android jni Android视频<JNI> http://edu.csdn.net/course/detail/3235/54186?auto_star ...
- android 中使用自定义权限
1.如果在一个进程中启动另外一个进程的activity <?xml version="1.0" encoding="utf-8"?> <man ...
- disruptor架构一
Disruptor是一个高性能的异步处理框架,或者可以认为是最快的消息框架(轻量的JMS),也可以认为是一个观察者模式的实现,或者事件监听模式的实现. 在使用之前,首先说明disruptor主要功能加 ...
- jvm基础知识1
堆放实例对象,栈放实例对象的引用,方法区存储创建类的信息 上面堆和垃圾回收的关系,垃圾回收回收的是堆内存的数据,s0和s1区域, 例如现在我们要清除s0中的堆对象,将s0中正在运行的对象从s0区域移动 ...
- JDK8--05:方法引用和构造器引用
在上一篇文章中,说过JDK8中内置的函数时接口,为了方便使用,JDK8还提供了方法引用和构造器引用,来简化lambda的写法 1.方法引用 方法引用说明:lambda表达式中的方法已经在其他方法中已经 ...
- Linux命令查勘进程:ps -ef |grep java
一.ps -ef |grep java 查看包含“java”的所有进程 二.涉及命令详解 ps命令将某个进程显示出来(是LINUX下最常用的也是非常强大的进程查看命令) grep命令是查找(是一种强大 ...
- Flutter 中那么多组件,难道要都学一遍?
在 Flutter 中一切皆是 组件,仅仅 Widget 的子类和间接子类就有 350 多个,整理的 Flutter组件继承关系图 可以帮助大家更好的理解学习 Flutter,回归正题,如此多的组件到 ...