#定义代码格式
#-*- coding:utf8 -*-
from urllib import request
from urllib import parse
from urllib.request import urlopen
url = "http://xapi.kybyun.com/user/login"
#定义请求数据并赋值
headers = {}
headers = {
'Host': 'xapi.kybyun.com',
'Connection': 'keep-alive',
'User-Agent': 'BangXueTang AipBot/1.0(BangXueTang-IOS/2.1.3.1;IOS/9.30;iPhone 6 Plus)',
'KY-UKEY': '940cd0dffd371d41eb0acbb7694fd5e9',
'KY-SYDEV': 'iPhone 6 Plus',
'KY-SPEID': '10010101',
'KY-SCHID': '1044',
'KY-APPCHG': 'AppStore',
'Connection': 'keep-alive',
'KY-UUID': '6ff7563dbd47c8077905c3920bc0d8b3',
'KY-YEAR': '2017',
'Accept-Language': 'zh-Hans-CN;q=1',
'KY-SYSVER': '9.3',
'Accept': '*/*',
'Content-Type': 'application/x-www-form-urlencoded',
'KY-APPVER': '2.1.3.1',
'KY-APPVERS': '4',
'KY-APPTYPE': '21'
}
data = {}
data['appchg'] = 'Appstore'
data['apptype'] = '21'
data['appver'] = '2.1.3.1'
data['email'] = 'mushishi01'
data['isblind'] = '0'
data['passwd'] = '111111'
data['sysdev'] = 'iPhone 6 Plus'
data['sysver'] = '9.3'
data['uuid'] = '6ff7563dbd47c8077905c3920bc0d8b3'
#对数据进行编码
data = parse.urlencode(data).encode(encoding='UTF8')
#对post的数据进行合并
req = request.Request(url, data, headers)
#打开请求获取对象
requestResponse = urlopen(req)
#读取服务端返回的对象
responseStr = requestResponse.read()
#将密码进行转译(因为密码用的是MD5的,对应上边)
ResponseStr = responseStr.decode("unicode_escape")
#打印数据
print(ResponseStr)