python 爬虫能否采集没有权限的页面内容

Python014

python 爬虫能否采集没有权限的页面内容,第1张

你这种情况,是因为浏览的是动态页面,源码是动态生成的,需要找到那个隐藏的url才能抓取。采用这种方式的网站很多,是为了快速显示相应的内容。解决方法要么找到可以显示内容的隐藏url,要么采用python的插件,将全部的内容显示出来后,读取源码,再抓取。

用urllib2

例如:

url = 'http://i.qq.com/'

data = {'name': 'username','password': '123456'}

post_data = urllib.urlencode(data)

req = urllib2.Request(url, post_data)

response = urllib2.urlopen(req)

page_content = response.read()

这个data这里是随便写的, 你自己用抓包工具看看是qq空间是什么样子的。