# coding=utf-8
import requests
import json
import re
def itc_service_key():
url = "https://itunesconnect.apple.com/itc/static-resources/controllers/login_cntrl.js"
req = requests.Session()
headers = {
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0',
'Accept-Encoding' : 'identity'
}
response = req.get(url, headers=headers).content
pattern = re.compile(r"itcServiceKey = '(.*)'")
itc_service_key = pattern.findall(response)
print itc_service_key[0]
return itc_service_key[0]
def cookie():
get_cookie = "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/route?noext"
r = requests.Session()
headers = {
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0',
}
response = r.get(get_cookie,headers=headers)
cookie = []
for keys in response.cookies:
cookie.append(keys.value)
return cookie[0]
itc_service_key = itc_service_key()
cookie = cookie()
print cookie
user = "xxxxxx"
password = "xxxxxxx"
req = requests.Session()
headers = {
'Content-Type' : 'application/json',
'X-Requested-With' : 'XMLHttpRequest',
'Accept' : 'application/json, text/javascript',
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:46.0) Gecko/20100101 Firefox/46.0',
'Content-Type' : 'application/x-www-form-urlencoded',
"Cookie" : cookie
}
data = {
"accountName": user,
"password": password,
"rememberMe": True
}
url = "https://idmsa.apple.com/appleauth/auth/signin?widgetKey="+itc_service_key
print url
response = req.post(url, headers=headers, data=json.dumps(data))
print response.status_code
print response.content
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.