Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from configparser import ConfigParser
- import requests
- from urllib.parse import urlparse, parse_qs
- import time
- import random
- import logging
- import sys
- from http.client import HTTPConnection
- from bs4 import BeautifulSoup
- # HTTPConnection.debuglevel = 1
- # logging.basicConfig()
- # logging.getLogger().setLevel(logging.DEBUG)
- # requests_log = logging.getLogger("requests.packages.urllib3")
- # requests_log.setLevel(logging.DEBUG)
- # requests_log.propagate = True
- country = 'HK'
- locale = 'en_HK'
- store = 'R499'
- part_number = 'MQA62ZP/A'
- url = {}
- url_params = {}
- proxies = {
- 'http': 'http://191.96.109.240:3199',
- 'https': 'https://191.96.109.240:3199'
- }
- # cfg = ConfigParser()
- # cfg.read('config.ini')
- # MYSQL_HOST = cfg.get('mysql-server', 'host')
- # MYSQL_PORT = cfg.getint('mysql-server', 'port')
- # MYSQL_USER = cfg.get('mysql-server', 'user')
- # MYSQL_PASSWORD = cfg.get('mysql-server', 'password')
- # MYSQL_DATABASE = cfg.get('mysql-server', 'database')
- # db = pymysql.connect(host=MYSQL_HOST, port=MYSQL_PORT, user=MYSQL_USER, password=MYSQL_PASSWORD, db=MYSQL_DATABASE, charset='utf8mb4')
- fn = 'debug.txt'
- def test():
- s = requests.Session()
- # s.verify = "charles.cer"
- # s.verify = False
- # response = s.request(
- # 'get',
- # 'https://ifconfig.co/ip',
- # proxies=proxies
- # )
- # print(response.text)
- # sys.exit()
- response = s.request(
- 'get',
- 'https://reserve-prime.apple.com/' + country + '/' + locale + '/reserve/iPhoneX',
- headers={
- 'Connection': 'keep-alive',
- 'Pragma': 'no-cache',
- 'Cache-Control': 'no-cache',
- 'Upgrade-Insecure-Requests': '1',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Accept-Language': 'en-US,en;q=0.8'
- },
- params={
- 'quantity': '2',
- 'store': store,
- 'partNumber': part_number,
- 'channel': '1',
- 'sourceID': '',
- 'iUID': '',
- 'iuToken': '',
- 'iUP': 'N',
- 'appleCare': '',
- 'rv': '',
- 'path': '',
- 'plan': 'unlocked'
- },
- proxies=proxies
- )
- if response.status_code != 200:
- print('step 1 failed invalid response code')
- if response.status_code == 403 and response.url == 'https://www.apple.com/' + country.lower() + '/iphone/':
- print('maybe stock-out')
- sys.exit()
- sp = BeautifulSoup(response.text, 'html.parser')
- if sp.select('title')[0].get_text() != 'Sign In - Apple':
- print('step 1 failed invalid page')
- sys.exit(0)
- signin_scnt = sp.select('#scnt')[0]['value']
- url['signin_page'] = response.url
- # https://signin.apple.com/IDMSWebAuth/signin?path=%2FAU%2Fen_AU%2Freserve%2FiPhone%3Fexecution%3De1s1%26p_left%3DAAAAAARVJ865qtn4hK8W1pG7eczwcmI45QNmcebdbu4mNGGKhw%253D%253D%26_eventId%3Dnext&p_time=1506399761&rv=1&language=AU-EN&p_left=AAAAAARVJ865qtn4hK8W1pG7eczwcmI45QNmcebdbu4mNGGKhw%3D%3D&appIdKey=db0114b11bdc2a139e5adff448a1d7325febef288258f0dc131d6ee9afe63df3
- fh = open(fn, 'a+')
- fh.writelines([
- str(response.status_code) + '\n',
- response.url + '\n',
- str(response.headers) + '\n',
- response.text + '\n',
- '\n'
- ])
- fh.close()
- qs = parse_qs(urlparse(response.url).query)
- url_params['path'] = qs['path'][0]
- url_params['rv'] = qs['rv'][0]
- url_params['language'] = qs['language'][0]
- url_params['p_left'] = qs['p_left'][0]
- url_params['appIdKey'] = qs['appIdKey'][0]
- time.sleep(1)
- response = s.request(
- 'get',
- 'https://signin.apple.com/appleauth/auth/signin',
- headers={
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- 'Accept-Language': 'en-US,en;q=0.8',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Referer': url['signin_page'],
- 'Connection': 'keep-alive',
- 'Upgrade-Insecure-Requests': '1'
- },
- params={
- 'widgetKey': '40692a3a849499c31657eac1ec8123aa',
- 'language': url_params['language']
- },
- proxies=proxies
- )
- if response.status_code != 200:
- print('signin widget failed')
- fh = open(fn, 'a+')
- fh.writelines([
- str(response.status_code) + '\n',
- response.url + '\n',
- str(response.headers) + '\n',
- response.text + '\n',
- '\n'
- ])
- fh.close()
- url['signin_widget'] = response.url
- generated_scnt = str(int(1e10 * random.random()))
- response = s.request(
- 'post',
- 'https://signin.apple.com/appleauth/jslog',
- headers={
- 'Connection': 'keep-alive',
- 'Pragma': 'no-cache',
- 'Cache-Control': 'no-cache',
- 'Accept': 'application/json',
- 'Origin': 'https://signin.apple.com',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'scnt': generated_scnt,
- 'Content-type': 'application/json',
- 'Referer': url['signin_widget'],
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Accept-Language': 'en-US,en;q=0.8'
- },
- json={
- "type": "INFO",
- "title": "AppleAuthDebug",
- "message": "APPLE ID : Launching AppleAuth application."
- },
- proxies=proxies
- )
- fh = open(fn, 'a+')
- fh.writelines([
- str(response.status_code) + '\n',
- response.url + '\n',
- str(response.headers) + '\n',
- response.text + '\n',
- '\n'
- ])
- fh.close()
- if response.status_code != 204:
- print('signin jslog failed')
- time.sleep(5)
- response = s.request(
- 'post',
- 'https://signin.apple.com/appleauth/auth/signin',
- headers={
- 'Connection': 'keep-alive',
- 'Pragma': 'no-cache',
- 'Cache-Control': 'no-cache',
- 'X-Apple-App-Id': '942',
- 'X-Apple-Widget-Key': '40692a3a849499c31657eac1ec8123aa',
- 'Origin': 'https://signin.apple.com',
- 'X-Apple-I-FD-Client-Info': '{"U":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36","L":"en-US","Z":"GMT+08:00","V":"1.1","F":".Ga44j1e3NlY5BSo9z4ofjb75PaK4Vpjt.gEngMQEjZrVglE4Ww.GEFF0Yz3ccbbJYMLgiPFU77qZoOSix5ezdstlYysrhsui6.Whtd9KKaKEhO3f9p_nH1u_eH3BhxUC550ialT0iakA2zGUMnGWFfwMHDCQyFA2wv4qnvtCsABIlNU.3Io3.Nzl998tp7ppfAaZ6m1CdC5MQjGejuTDRNziCvTDfWk7QTPH_KO_IvLG9mhORoVjnjk3nKxUC54bQIxtzE9XXTneNufuyPBDjaY2ftckuyPB884akHGOg4C10EQh9dJ8aDhk6Hb9LarUqUdHz16rgPtTma1kxNGYicpw.Tf5.EKYgRc0mX3ivmeUeJzWKvqCSFQ_v9NA1OKq7GY5BNve.BNlYCa1nkBMfs.1av"}',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'X-Apple-Locale': url_params['language'],
- 'Content-Type': 'application/json',
- 'Accept': 'application/json, text/javascript, */*; q=0.01',
- 'X-Requested-With': 'XMLHttpRequest',
- 'Referer': url['signin_widget'],
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Accept-Language': 'en-US,en;q=0.8'
- },
- json={
- "accountName": "Mark0202@ireserve.fun",
- "password": "1qaz@WSX3edc$RFV5tgb^YHN7ujm*IK<",
- "rememberMe": False
- },
- proxies=proxies
- )
- if response.status_code != 200:
- print('signin failed')
- fh = open(fn, 'a+')
- fh.writelines([
- str(response.status_code) + '\n',
- response.url + '\n',
- str(response.headers) + '\n',
- response.text + '\n',
- '\n'
- ])
- fh.close()
- time.sleep(1)
- response = s.request(
- 'post',
- 'https://signin.apple.com/IDMSWebAuth/signin',
- headers={
- 'Connection': 'keep-alive',
- 'Pragma': 'no-cache',
- 'Cache-Control': 'no-cache',
- 'Origin': 'https://signin.apple.com',
- 'Upgrade-Insecure-Requests': '1',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
- 'Referer': url['signin_page'],
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Accept-Language': 'en-US,en;q=0.8'
- },
- data={
- 'rememberMe': 'false',
- 'appIdKey': url_params['appIdKey'],
- 'language': url_params['language'],
- 'path': url_params['path'],
- 'rv': url_params['rv'],
- 'scnt': signin_scnt
- },
- proxies=proxies
- )
- fh = open(fn, 'a+')
- fh.writelines([
- str(response.status_code) + '\n',
- response.url + '\n',
- str(response.headers) + '\n',
- response.text + '\n',
- '\n'
- ])
- fh.close()
- if response.status_code != 200:
- print('post signin failed')
- sys.exit(0)
- sp = BeautifulSoup(response.text, 'html.parser')
- if sp.select('title')[0].get_text() == 'Your Registration Code - Apple':
- url['current'] = response.url
- response = s.request(
- 'get',
- url['current'] + '&ajaxSource=true&_eventId=context',
- headers={
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'Accept': '*/*',
- 'Accept-Language': 'en-US,en;q=0.8',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Referer': url['current'],
- 'Connection': 'keep-alive'
- },
- proxies=proxies
- )
- if response.status_code != 200:
- print('request sms code error')
- sys.exit(0)
- response_data = response.json()
- # {
- # "firstTime": true,
- # "path": "",
- # "storeNumber": "R386",
- # "phoneCountryCode": "61",
- # "rv": "0",
- # "hcID": "tgSEoSTSZR/10CBiUOva2A4zNxU=",
- # "hcd": "0x00000000",
- # "partNumber": "MQ6M2X/A",
- # "keyword": "IPY7TS1HY9",
- # "_flowExecutionKey": "e1s2",
- # "appleCare": false,
- # "p_ie": "5ce2eb92-88e8-4739-bf4b-a655dbf09aaa"
- # }
- print(response_data)
- sys.exit()
- s.request(
- 'post',
- url['current'],
- headers={
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- 'Accept-Language': 'en-US,en;q=0.8',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Referer': url['current'],
- 'Connection': 'keep-alive',
- 'Upgrade-Insecure-Requests': '1'
- },
- data={
- 'phoneCountryCode': response_data['phoneCountryCode'],
- 'phoneNumber': '55112345',
- 'registrationCode': 'agda2s',
- '_eventId': 'next',
- '_flowExecutionKey': response_data['_flowExecutionKey'],
- 'p_ie': response_data['p_ie'],
- 'dims': 'kWa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt4U_A6icW1F7MpwoNN5uQ1szHVyVxFAk.rVQdgAYx92u2p.j.2UMnGWFfwMHDCQyGMtHXTIKSEU0H8uszHVyVxFAk.XTrLjn.hlzuTDRI_37H02lLnU8zXVb50alnjk3nKxUC54jYE5ura1XmpRnmccbguaDeyjaY2ftckuyPBDjaY1HGOg3ZLQ0IFmaH1J9XWIUfR0odm_dhrxbuJjkWxv5iMgdVgEKXudQNvr9ey.EKY.6ekL3vgRcWAiwAwebu_TxYMJ5tTma1kxL57GYPrsiMTKQnlLZnjLHi5hyA_r_LwwKdBvzKAQxi3NlYic.lY5BqNAE.lTjV.CeN',
- 'dims': 's8a44j1e3NlY5BSo9z4ofjb75PaK4Vpjt4U_98uszHVyVxFAk.lzXJJIneGffLMC7EZ3QHPBirTYKUowRslzRQqwSM2V9htx39gkaxf7_OLgiPFMJhHFW_jft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scHc': 'a=5668008,b=10719,c=0.8899999999994179,d=102.67000000000007',
- 'miscHc': 'a=1159657,b=4789,c=0.5649999999950523,d=108.98000000000002'
- }
- )
- # response = s.request(
- # 'post',
- # 'https://reserve-prime.apple.com/AU/en_AU/reserve/iPhone?execution=e1s2',
- # headers={
- # 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0'
- # # Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
- # # Accept-Language en-US,en;q=0.5
- # # Accept-Encoding gzip, deflate, br
- # # Content-Type application/x-www-form-urlencoded
- # # Referer https://reserve-prime.apple.com/AU/en_AU/reserve/iPhone?execution=e1s2
- # # Connection keep-alive
- # # Upgrade-Insecure-Requests 1
- # },
- # data={
- # # timeslot 5s4tzcpsCoZSzLPtcjfg2Cx7k5Av6mTFSPeqDxPQtZUiVk0lBnm3xK_E9jPJmHX2aLHFxwzPr6s6TJvUGiC2qi0ICn4fTHjUllOxOMg=_#_UHWhe-8cVqK6wZH07s07RwUUtOs.
- # # date 1506434400000
- # # firstName R
- # # lastName Leung
- # # email y2kbugleung@gmail.com
- # # phoneCountryCode 61
- # # phoneNumber abcde
- # # _eventId next
- # # _flowExecutionKey e1s2
- # # p_ie c64388fd-98d9-4ff3-aadf-f7ef70c1ae60
- # # dims kWa44j1e3NlY5BSo9z4ofjb75PaK4Vpjt4U_A6icW1F7MpwoNN5uQ1szHVyVxFAk.rVQdgAYx92u2p.j.2UMnGWFfwMHDCQyGMtHXTIKSEU0H8uszHVyVxFAk.XTrLjn5hlzuTDRI_37H02lLnU8zXVb5Calnjk3nKxUC54jYE5ura1XmpRnmccbguaDeyjaY2ftckuyPBDjaY1HGOg3ZLQ0IFV2pAAq_HNhyhk6Hb9LarUqUdHz16rgPtTma1kxLAe_hYjUfU.6elV2pNv69_DJF_rTJfy6gzCAwHCSFQ_v9NA2pNNW5CfUXtStKjE4PIDxO9sPrsiMTKQnlLZnjxJhjqsGY5DuV25BNnOVgw24uy.6T_
- # }
- # )
- test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement