|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
程序功能为爬取腾讯视频评论。在pycharm中无法调试成功,但是python3.7IDLE中却能成功,向各位鱼油求助原因,谢谢大家!
源代码如下:
import urllib.request
import re
import urllib.error
headers=("user-agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0")
opener=urllib.request.build_opener()
opener.addheaders=[headers]
urllib.request.install_opener(opener)
comment_id="6468073927382762387"
url="https://video.coral.qq.com/varticle/3431979175/comment/v2?callback=_varticle3431979175commentv2&orinum=10&oriorder=o&pageflag=1&cursor="+comment_id+"&scorecursor=0&orirepnum=2&reporder=o&reppageflag=1&source=9&_=1542282914671"
for i in range(0,29):
data=urllib.request.urlopen(url).read().decode()
pat_next='"last":"(.*?)"'
next_id=re.compile(pat_next).findall(data)[0]
pat_comment='"content":"(.*?)",'
comment_data=re.compile(pat_comment).findall(data)
for j in range(0,len(comment_data)):
print("-----第"+str(i)+str(j)+"条评论内容是:")
print(eval('u"'+comment_data[j]+'"'))
url="https://video.coral.qq.com/varticle/3431979175/comment/v2?callback=_varticle3431979175commentv2&orinum=10&oriorder=o&pageflag=1&cursor="+next_id+"&scorecursor=0&orirepnum=2&reporder=o&reppageflag=1&source=9&_=1542282914671"
pycharm中显示的问题如图 |
-
pycharm中显示的问题
|