复制代码 代码如下:
# -*- coding:utf-8 -*-
# python3.3.3
import sys,time,re,urllib.parse,urllib.request,http.cookiejar,random,math,os.path,hashlib,json,binascii,threading
"""cookie"""
cookie=http.cookiejar.LWPCookieJar()
#cookie.load('f:/cookie.txt',True,True)
chandle=urllib.request.HTTPCookieProcessor(cookie)
"""获取数据"""
def getData(url):
r=urllib.request.Request(url)
opener=urllib.request.build_opener(chandle)
u=opener.open(r)
#chandle.cookiejar.save('f:/cookie.txt',True,True)
data=u.read()
try:
data=data.decode('utf-8')
except:
data=data.decode('gbk','ignore')
return data
def postData(url,data):
data=urllib.parse.urlencode(data);data=bytes(data,'utf-8')
r=urllib.request.Request(url,data)
opener=urllib.request.build_opener(chandle)
u=opener.open(r)
#chandle.cookiejar.save('f:/cookie.txt',True,True)
data=u.read()
try:
data=data.decode('utf-8')
except:
data=data.decode('gbk','ignore')
return data
def login(name,pwd):
url='http://www.baidu.com'
getData(url)
par={
"apiver":'v3',
"callback":'bd__cbs__oug2fy',
"class":'login',
"logintype":'dialogLogin',
"tpl":'tb',
"tt":'1385013373144'
}
url='https://passport.baidu.com/v2/api/?getapi&%s' % urllib.parse.urlencode(par)
token=re.findall('"token" : "(.*?)"',getData(url))[0]
par.update({"isphone":'false',"username":name,"token":token})
url='https://passport.baidu.com/v2/api/?logincheck&?%s' % urllib.parse.urlencode(par)
data={
"charset":'GBK',
"mem_pass":'on',
"password":pwd,
"ppui_logintime":'1612376',
"quick_user":'0',
"safeflg":'0',
"splogin":'rate',
"u":'http://tieba.baidu.com/'
}
url='https://passport.baidu.com/v2/api/?login'
par.update(data)
bdu=re.findall('hao123Param=(.*?)&',postData(url,par))[0]
par={
"bdu":bdu,
"t":'1385013373144'
}
url='http://user.hao123.com/static/crossdomain.php?%s' % urllib.parse.urlencode(par)
getData(url)
print(json.loads(getData('http://tieba.baidu.com/f/user/json_userinfo')))
"""------输入帐号密码------"""
login('帐号','密码')
复制代码 代码如下:
# -*- coding:utf-8 -*-
# python3.3.3
import sys,time,re,urllib.parse,urllib.request,http.cookiejar,random,math,os.path,hashlib,json,binascii,threading
"""cookie"""
cookie=http.cookiejar.LWPCookieJar()
#cookie.load('f:/cookie.txt',True,True)
chandle=urllib.request.HTTPCookieProcessor(cookie)
"""获取数据"""
def getData(url):
r=urllib.request.Request(url)
opener=urllib.request.build_opener(chandle)
u=opener.open(r)
#chandle.cookiejar.save('f:/cookie.txt',True,True)
data=u.read()
try:
data=data.decode('utf-8')
except:
data=data.decode('gbk','ignore')
return data
def postData(url,data):
data=urllib.parse.urlencode(data);data=bytes(data,'utf-8')
r=urllib.request.Request(url,data)
opener=urllib.request.build_opener(chandle)
u=opener.open(r)
#chandle.cookiejar.save('f:/cookie.txt',True,True)
data=u.read()
try:
data=data.decode('utf-8')
except:
data=data.decode('gbk','ignore')
return data
def login(name,pwd):
url='http://www.baidu.com'
getData(url)
par={
"apiver":'v3',
"callback":'bd__cbs__oug2fy',
"class":'login',
"logintype":'dialogLogin',
"tpl":'tb',
"tt":'1385013373144'
}
url='https://passport.baidu.com/v2/api/?getapi&%s' % urllib.parse.urlencode(par)
token=re.findall('"token" : "(.*?)"',getData(url))[0]
par.update({"isphone":'false',"username":name,"token":token})
url='https://passport.baidu.com/v2/api/?logincheck&?%s' % urllib.parse.urlencode(par)
data={
"charset":'GBK',
"mem_pass":'on',
"password":pwd,
"ppui_logintime":'1612376',
"quick_user":'0',
"safeflg":'0',
"splogin":'rate',
"u":'http://tieba.baidu.com/'
}
url='https://passport.baidu.com/v2/api/?login'
par.update(data)
bdu=re.findall('hao123Param=(.*?)&',postData(url,par))[0]
par={
"bdu":bdu,
"t":'1385013373144'
}
url='http://user.hao123.com/static/crossdomain.php?%s' % urllib.parse.urlencode(par)
getData(url)
print(json.loads(getData('http://tieba.baidu.com/f/user/json_userinfo')))
"""------输入帐号密码------"""
login('帐号','密码')
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- 战锤40K星际战士2狙击职业介绍|狙击职业技能效果一览
- RobertSaxtonTheResurrectionoftheSoldiers(2024)[24Bit-192kHz]FLAC
- 唐成杨东哥弹唱《情若真HQ》头版限量编号[WAV+CUE]
- 柏菲·HIFI风情1《一杯香茶》限量开盘母带ORMCD[WAV+CUE]
- 发糖了!《黑神话》动画导演绘制八戒紫蛛儿中秋贺图
- “时光系列”新作《时光3:永耀之境》首曝:画风更真实的恋爱模拟RPG
- 《战地》游戏主管:始终认为《战地》未来销量能超越《使命召唤》
- 《伤感民谣 值得收藏的音乐极品 2CD》[WAV/分轨][1.2GB]
- 《邓紫棋 巨肺唱将小天后有心人 2CD》[WAV/分轨][1.2GB]
- 《迪克牛仔 坛奇精选 2CD台首版》 [WAV+CUE][600MB]
- 陈明.1998-为了爱影视歌曲+新歌【中唱】【WAV+CUE】
- 黄小琥.2009-简单/不简单【华纳】【WAV+CUE】
- 洪卓立.2010-TASTE.OF.LOVE新曲+精丫英皇娱乐】【WAV+CUE】
- 战锤40K星际战士2职业强度排行
- 交错战线PVE国家队成员以及常用角色推荐