想要获取微信公众号文章的阅读数与点赞数,通过fiddler抓包得到了阅读数和点赞数的网页链接,设置了爬虫的user-agent伪装成手机,程序如下:
url = 'https://mp.weixin.qq.com/mp/getappmsgext?__biz=MzA5NjY2NTcxOA==&appmsg_type=9&mid=2650376241&sn=65c82daac95e525f85cf02f039531786&idx=1&scene=4&title=%E4%B8%AD%E5%9B%BDvs%E6%B3%95%E5%9B%BD%EF%BC%9A%E5%B9%B4%E8%BD%BB%E5%B0%B1%E6%98%AF%E8%B5%B7%E4%BC%8F%E4%B8%8D%E5%AE%9A%E7%9A%84%E8%A1%80%E6%B0%94&ct=1470716889&devicetype=Windows 10&version=&f=json&r=0.5993161727674305&is_need_ad=0&comment_id=1104587265&is_need_reward=1&both_ad=1&reward_uin_count=51&uin=MjgzMTc4ODIyMA%253D%253D&key=8dcebf9e179c9f3aeece758ae65104c3f4605c302f9d312c4290d9c1d8ae475030f6ac42bb09cf0d0aec29985eb0096a&pass_ticket=Xaf8nqmYjt15YnkFFeztDkErcE83DOtY6HkmXzw5jfm7xqCMfEJL11BTvOOr0oM3&wxtoken=2462562545&devicetype=Windows%26amp%3Bnbsp%3B10&clientversion=62000058&x5=0'
header = {'User-Agent':'Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11D257 MicroMessenger/5.3.1like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4',
'Host':'mp.weixin.qq.com'}
html = requests.get(url, headers = header,verify = False).content
print html
运行结果是: