web crawling(plus2) comment crawling

Posted 兔子的尾巴_Mini

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了web crawling(plus2) comment crawling相关的知识,希望对你有一定的参考价值。

#Author:Mini
#!/usr/bin/env python
import urllib.request
import re
import urllib.error
headers=("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0")
opener=urllib.request.build_opener()
opener.addheaders=[headers]
urllib.request.install_opener(opener)
comid="6315179284605088209"
for i in range(4,7):
url="https://coral.qq.com/article/1003390161/comment?commentid="+comid+"&reqnum=20&tag=&callback=jQuery112409214906389806301_1507082215770&_=150708221577"+str(i)

data=urllib.request.urlopen(url).read().decode("utf-8","ignore")
patnext=‘"last":"(.*?)"‘
nextid=re.compile(patnext).findall(data)[0]
patcom=‘"content":"(.*?)",‘
comdata=re.compile(patcom).findall(data)
for j in range(0,len(comdata)):
print(str(i)+"."+str(j)+"comment:")
print(eval(‘u"‘+comdata[j]+‘"‘))
url="https://coral.qq.com/article/1003390161/comment?commentid="+nextid+"&reqnum=20&tag=&callback=jQuery112409214906389806301_1507082215770&_=150708221577"+str(i)
print(url)






















以上是关于web crawling(plus2) comment crawling的主要内容,如果未能解决你的问题,请参考以下文章

web crawling(plus5) crawling wechat

web crawling(plus5) news crawling and proxy

web crawling

web crawling(plus1)

web crawling(plus10)scrapy 4

web crawling(plus3) errors solution