如果出现错误:SyntaxError: Non-ASCII character '\xe7'
就在第一行加上下面这行即可:
#-*- coding: UTF-8 -*-
就在第一行加上下面这行即可:
#-*- coding: UTF-8 -*-
2018-01-24
python 3.6.0 版本下代码参考,完成作业的时候遇到问题也有参考前面同学的代码进行了修改,希望后面来学习的小伙伴都可以顺利完成,得到提升。
https://github.com/zhangyan123/PythonCrawler
https://github.com/zhangyan123/PythonCrawler
使用requests遇到TooManyRedirects:Exceeded 30 redirects的错误,加入User-Agent就行了:
s = requests.session()
s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36'
r = s.get(url)
r.encoding = 'utf-8'
s = requests.session()
s.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36'
r = s.get(url)
r.encoding = 'utf-8'
2018-01-20
解决中文编译失败在文件头部添加:# -*- coding: cp936 -*-或
# -*- coding: utf-8 -*
# -*- coding: utf-8 -*
2018-01-17
https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup
2018-01-17
对着代码打,然后换成python3版本的还是会报错呀
File "first.py", line 1, in <module>
from urllib import request
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 84, in <module>
File "first.py", line 1, in <module>
from urllib import request
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 84, in <module>
2018-01-17