|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
人人影视上线了,上面的资源很眼馋,但是又懒得去一个个下,想做个爬虫爬爬爬。目前卡在登录上。很忧伤,还想请教各位大神。
目前代码如下:
现在目前有点弄不清楚接下来是哪里出了问题。想求救各位大神。
import requests
login_url = 'http://www.zmz2017.com/User/Login/ajaxLogin'
login_headers = {
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'en-US,en;q=0.8,ja;q=0.6,zh-CN;q=0.4,zh-TW;q=0.2',
'Connection':'keep-alive',
'Content-Length':'89',
'Content-Type':'application/x-www-form-urlencoded',
'Host':'www.zmz2017.com',
'Origin':'http://www.zmz2017.com',
'Referer':'http://www.zmz2017.com/user/login',
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
'X-Requested-With':'XMLHttpRequest'}
login_data = {
'account':'????????',
'password':'????????',
'remember':'1',
'url_back':'http://www.zmz2017.com/'}
z1 = requests.post(url=login_url,data=login_data,headers=login_headers)
print(z1.status_code)
print(z1.content)
login_headers['Cookie'] = z1.headers['Set-Cookie']
mylog = 'http://www.zmz2017.com/resource/list/11057'
z2 = requests.get(url = mylog, headers=login_headers)
print(z2.status_code)
print(z2.url)
哎哟,这个我昨天才爬过!
用request.post,当时是登录进去了,但是跳转页面就又变成未登录了。
用session去post,这样才能保持会话,然后在session下面去跳转页面,就可以保持登录了。
如果想要下载,再跳转进去就可以看见下载链接了。而且现在新出了一个免登录就可以看见下载链接的链接,直接请求那个,应该也可以直接获得下载链接。
然而最大的问题,其实把链接爬下来也没什么用。自己电脑里面做数据库用起来感觉也不会比在网站上面用的快。
|
|