?#定義代碼格式
#-*-?coding:utf8?-*-
from?urllib?import?request
from?urllib?import?parse
from?urllib.request?import?urlopen
url?=?"http://reg.haibian.com/login/ajax_login"
#定義請求數(shù)據(jù)并賦值
data?=?{}
data['loginname']?=?'student08@qq.com'
data['password']?=?'111111'#密碼應(yīng)該是MD5的,在百度翻譯,這里不知道為什么明文就可以通過
data?=?parse.urlencode(data)
#將數(shù)據(jù)和url進行連接
requests?=?url+'?'+data
#打開請求獲取對象
requestResponse?=?urlopen(requests)
#讀取服務(wù)端返回的對象
responseStr?=?requestResponse.read()
#打印數(shù)據(jù)
#ResponseStr?=?responseStr.decode("unicode_escape")???#將密碼進行轉(zhuǎn)譯(因為密碼用的是MD5的,對應(yīng)上邊)
print(responseStr)
2019-05-22
第10行密碼沒有加密成MD5就可以通過應(yīng)該是URL改成了明文
19行這個不是密碼轉(zhuǎn)譯,是URL返回的json數(shù)據(jù)是unicode_escape格式的編碼,采用decode將它反義成我們能看的string類型的字符串