其他分享
首页 > 其他分享> > pyhton爬取爱豆(李易峰)微博评论

pyhton爬取爱豆(李易峰)微博评论

作者:互联网

今日目标:微博,以李易峰的微博为例: ```python https://weibo.com/liyifeng2007?is_all=1 ``` 然后进入评论页面,进入XHR查找真是地址: ```python https://weibo.com/aj/v6/comment/big?ajwvr=6&id=4353796790279702&from=singleWeiBo ``` 很明显,是动态的,抓取也是按我以前写的那些方法来,就不一一说了,他这里最重要的还是那串数字,所以我们只要在第一个网址哪里把那串数字找出来就算成功一半了,这次需要用到re正则,嗯,这个我不擅长,不过没事,应该还是可以搞到的: ```python target = 'https://weibo.com/liyifeng2007?is_all=1' headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36', 'cookie': 'SUB=_2AkMowDDgf8NxqwJRmPoSyWnqao53ywzEieKenME7JRMxHRl-yT9kqnEjtRB6A0AeDzsLF_aeZGlWOMf4mEl-MBZZXqc_; SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9WWcpq860VQlJcIRRNP9pzqS; SINAGLOBAL=1033839351635.7524.1604108279474; login_sid_t=c071efc77911ceace152df2be5986e09; cross_origin_proto=SSL; WBStorage=8daec78e6a891122|undefined; _s_tentry=-; Apache=8275565331127.246.1604195643561; ULV=1604195643568:3:1:1:8275565331127.246.1604195643561:1604122447982; wb_view_log=1920*10801; UOR=,,editor.csdn.net' } html = requests.get(target,headers=headers).text for each in re.findall('(.*?)

标签:weibo,liyifeng2007,python,pyhton,headers,微博,https,李易峰,com
来源: https://blog.51cto.com/u_11949039/2954620