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
第十一届蓝桥杯 b组企业网络拓扑图让Mac系统始终不休眠的设置技巧抢红包算法--四种抢红包算法对比深入了解vuex,vuex的五个核心属性转换后台返回的这种时间格式2019-04-24T02:30:00.000+00002020年了,前端还有的搞么?要怎么学?Python类(一)BPMN流程图postman简单教程 - - 增删改查接口测试(超详细)