Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3无法使用 #23

Open
jaq1217 opened this issue Oct 4, 2019 · 3 comments
Open

python3无法使用 #23

jaq1217 opened this issue Oct 4, 2019 · 3 comments

Comments

@jaq1217
Copy link

jaq1217 commented Oct 4, 2019

作者你好,这段代码在python3上边无法直接使用。我是初学,看了一下代码 好像urllib2等模块是在python2上边使用的,其他原因还未找到,还在学习。请指教 谢谢

@zhousodo
Copy link

把 urlib2 所用的库都换成urlib 因为python3 中 已经把urlib2所有的内容都集成到urlib.request 中.可以参考网上对照表,就可以了参考链接::https://blog.csdn.net/wds2006sdo/article/details/52730863
最后,我也是新手,可以一起交流

@FelixMundial
Copy link

@zhousodo @jaq1217

把 urlib2 所用的库都换成urlib 因为python3 中 已经把urlib2所有的内容都集成到urlib.request 中.可以参考网上对照表,就可以了参考链接::blog.csdn.net/wds2006sdo/article/details/52730863
最后,我也是新手,可以一起交流

您好,已在作者repo基础上重构为Python 3.8版本,现支持JSON格式的数据导出,以及图书封面、详情与评论模块的数据爬取:SimpleDoubanScraper

@ZoeChen04616
Copy link

代码里面有些部分python3已经不支持了,以下是我发现的一些报错和修改:
1.AttributeError: module 'urllib' has no attribute 'quote'
原因:在Python 3中,quote函数已经移动到了urllib.parse模块中,调用方式应该改为:import urllib.parse
2. python3默认为utf8编码,不需要在开头import sys然后说明。
3. soup = BeautifulSoup(plain_text)的一个警告
该警告表明在创建BeautifulSoup对象时没有显式地指定解析器.可以将解析器设置为"lxml",可以改成:
soup = BeautifulSoup(plain_text, features="lxml")。代码里面有两处都要改,不然还是会报错。
我也是初学者,共勉!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants