复制代码 代码如下:
#-*-coding:utf-8-*-
'''
Created on 2014年1月10日
@author: hhdys
'''
import urllib.request,http.cookiejar,re
class Baidu:
def login(self):
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36')]
resp=opener.open('http://weigou.baidu.com/')
for c in cj:
print(c.name,"====",c.value)
getapiUrl = "https://passport.baidu.com/v2/api/?getapi&class=login&tpl=mn&tangram=true"
resp2=opener.open(getapiUrl)
getapiRespHtml = resp2.read().decode("utf-8")
foundTokenVal = re.search("bdPass\.api\.params\.login_token='(?P<tokenVal>\w+)';", getapiRespHtml)
if foundTokenVal :
tokenVal = foundTokenVal.group("tokenVal")
print(tokenVal)
staticpage = "http://zhixin.baidu.com/Jump/index?module=onesite"
baiduMainLoginUrl = "https://passport.baidu.com/v2/api/?login"
postDict = {
'charset':"utf-8",
'token':tokenVal,
'isPhone':"false",
'index':"0",
'staticpage': staticpage,
'loginType': "1",
'tpl': "mn",
'callback': "parent.bd__pcbs__n1a3bg",
'username':"*****", #用户名
'password':"*****", #密码
'mem_pass':"on",
"apiver":"v3",
"logintype":"basicLogin"
}
postData = urllib.parse.urlencode(postDict);
postData = postData.encode('utf-8')
resp3=opener.open(baiduMainLoginUrl,data=postData)
for c in cj:
print(c.name,"="*6,c.value)
if __name__=="__main__":
print("="*10,"开始")
bd=Baidu()
bd.login()
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 魏新雨《为你祈祷+新歌精逊2CD[WAV]
- 影心、明萨拉你选哪个?国外美女COS《博德3》
- 澳洲女子骑车跌入“自杀树”丛 疼痛持续9个月崩溃
- 育碧公布2024“她创力”计划:为女性游戏人提供辅导
- 刘美君.2017-千色·30总选3CD【环球】【WAV+CUE】
- 群星.2022-星河长明电视原声带【乐有奇思】【FLAC分轨】
- 陈淑桦.1995-淑桦盛开Forever【滚石】【WAV+CUE】
- 《再来一张》评测:出师成败皆系“赌”
- 《银河汉堡店》测评:我是银河走菜王!
- 《末日地带2》评测:酣畅淋漓的“和面”之旅
- 萧煌奇《没事的》[320K/MP3][96.22MB]
- 萧煌奇《没事的》[FLAC/分轨][263.38MB]
- 群星《音你而来 第6期》[320K/MP3][90.61MB]
- 交错战线爬塔攻略一览
- 战锤40K星际战士2全近战武器使用教学|近战武器连招表