#腾讯视频爬取评论
import urllib.request
import re
import urllib.error
import ssl #当使用urllib.urlopen打开一个 https 链接时,会验证一次 SSL 证书.全局取消证书验证
ssl._create_default_https_context = ssl._create_unverified_context
headers=('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:59.0) Gecko/20100101 Firefox/59.0') #User agent
opener=urllib.request.build_opener()#添加对应的报头信息
opener.addheaders=[headers]
urllib.request.install_opener(opener)#设opener为全局
comid='6365504907156083559'
url='https://video.coral.qq.com/varticle/1909645650/comment/v2?callback=_varticle1909645650commentv2&orinum=10&oriorder=o&pageflag=1&cursor='+comid+'&scorecursor=0&orirepnum=2&reporder=o&reppageflag=1&source=9&_=1523451466201'
for i in range(0,2):
try:
data=urllib.request.urlopen(url).read().decode()
p
腾讯视频爬取评论
最新推荐文章于 2024-04-10 08:32:49 发布