catmario 最近的时间轴更新
catmario

catmario

V2EX 第 84634 号会员,加入于 2014-12-01 14:28:26 +08:00
catmario 最近回复了
2015-02-11 15:07:50 +08:00
回复了 catmario 创建的主题 Python 请问知道百度云链接和密码,如何将资源保存至网盘
@t6attack 感谢回复。我跟踪post请求,并构造了登录请求。请问为什么还是进入不了转存界面,prin页面t的结果还是有“输入提取密码”?
------------------------------------------------------------
# -*- coding: utf8 -*-
import urllib2
import urllib

#原网页
url = 'http://pan.baidu.com/s/1GrM2M'
code = '1xpe'

#设置log
httpHandler = urllib2.HTTPHandler(debuglevel=1)
httpsHandler = urllib2.HTTPSHandler(debuglevel=1)
opener = urllib2.build_opener(httpHandler, httpsHandler)
urllib2.install_opener(opener)


#构造登录请求参数
postData1 = {
'pwd' : code,
'vcode' : '',
};
postData1 = urllib.urlencode(postData1);

#发送登录请求
loginRequest1 = urllib2.Request(url);
loginRequest1.add_header('Accept','*/*');
#loginRequest1.add_header('Accept-Encoding','gzip, deflate');
loginRequest1.add_header('Accept-Language','en-US,en;q=0.8,ja;q=0.6,zh-CN;q=0.4,zh-TW;q=0.2');
loginRequest1.add_header('Connection','keep-alive');
loginRequest1.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safari/537.36');
loginRequest1.add_header('Content-Type','application/x-www-form-urlencoded');
loginRequest1.add_header('X-Requested-With','XMLHttpRequest');

#网页读取
htm = urllib2.urlopen(loginRequest1)
print htm.read()
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3655 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 04:16 · PVG 12:16 · LAX 20:16 · JFK 23:16
Developed with CodeLauncher
♥ Do have faith in what you're doing.