记录学习python爬虫遇到的问题

1,urllib

    碰到的第一个问题就是python3不支持urllib.urlope()方法,解决方法是引用urillib.request.urlopen();

2,爬取的网页中文显示x89/x86/x45

   python3输出位串,而不是可读的字符串,需要转化,使用str(string,'ecoding')进行转化就可一解决

3,对urllib中的data参数进行构造

   需要引入urllib下的parse,同时需要记住提交类型不能是string,应该是byte类型。写法:parse.urlencode(data).encode('编码类型')

4,python 报错 typeError:an integer is required (got type dict)

原因:headers不能用urllib.request.urlopen()直接访问,需要先用urllib.request.Request()

5,threading.current_thread()详解

解答:返回当前的线程对象。链接:https://blog.csdn.net/shennongzhaizhu/article/details/51544151

6,多线程:threading.current_thread().name和.getName()有什么区别

解答:name 是当前线程的属性, getName 是当前线程的方法。

猜你喜欢

转载自blog.csdn.net/a13103861409/article/details/80266169
今日推荐