V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  catmario  ›  全部回复第 1 页 / 共 1 页
回复总数  1
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   ·   实用小工具   ·   987 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 9ms · UTC 20:00 · PVG 04:00 · LAX 12:00 · JFK 15:00
Developed with CodeLauncher
♥ Do have faith in what you're doing.