Python爬虫所见问题集合:

1. NotImplementedError: Only the following pseudo-classes are implemented:
nth-of-type

Answer:nth-child 改为 nth-of-type

3.expected string or bytes-like object:

Answer:进行编码转换。

eg:re.findall(r’’,html.decode(‘utf-8’))

4. 'gbk' codec can't encode character '\xa5' in position 184823: illegal
multibyte sequence

Answer:f = open(html,’w’,encoding = ‘utf-8’)

5. 网页乱码问题:中文乱码

Answer :response = requests.get(url,headers = header).content

#content解决乱码

6. expected string or bytes-like object

Answer:转换为字符串格式,str(urls)

urls = soup.select(' div > div.nei_left.fl > ul > li:nth-of-type(2)> a')[0]

Href = re.findall(r'<a href="(.*?)" target="" title=".*?">(.*?)</a>',str(urls))

7.  Raise URLError (err)  <urlopen error [Errno 11001] getaddrinfo failed>

通常,URLError在没有网络连接(没有路由到特定服务器),或者服务器不存在的情况下产生

技术
©2020 ioDraw All rights reserved
计算机二级python综合应用题(三)【C语言】乘法表面试简历上的项目经验前端实习生必看(前端实习需要达到什么水平)STM32 RS485 modbus通讯源程序,亲测有效JavaScript学习(作用域)《程序是怎么跑起来的》第十一章 硬件控制方法用户登录界面原型图消息称华为招聘半导体设备人才 网友:光刻机是刚需react后台管理配置路由及侧边栏: