-
-
Save code-scan/34f351f68adc8b31db3a5bb59eabe9ea to your computer and use it in GitHub Desktop.
WeChat Pay Bill Export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import datetime | |
# Simply call get_record and it will return a json object containing your bill. | |
# Replace them with your credentials. You can get all these credentials by capturing packets from WeChat app when viewing your bill. Hint: Surge.app can be very helpful. | |
exportkey = "xxxxxx" | |
cookie = "export_key=xxxxx; userroll_pass_ticket=xxxxxx" | |
last_id = "xxxxx" | |
def get_record(y,m,d,count): | |
# https://wx.tenpay.com/userroll/userrolllist | |
# GET https://wx.tenpay.com/userroll/userrolllist | |
timestamp = datetime.datetime(y,m,d,0,0).timestamp() | |
global exportkey, cookie, last_id | |
if count > 200: # Cannot be greater than 200 per query. | |
count = 200 | |
try: | |
response = requests.get( | |
url="https://wx.tenpay.com/userroll/userrolllist", | |
params={ | |
"exportkey": exportkey, | |
"count": str(count), | |
"sort_type": "1", | |
"start_time": str(timestamp), | |
"classify_type": "3", | |
"last_bill_id": last_id, | |
}, | |
headers={ | |
"Cookie": cookie, | |
"Accept": "*/*", | |
"Connection": "keep-alive", | |
"Referer": "https://wx.tenpay.com/", | |
"Accept-Encoding": "gzip, deflate", | |
"Host": "wx.tenpay.com", | |
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 10_2 like Mac OS X) AppleWebKit/602.3.12 (KHTML, like Gecko) Mobile/14C92 MicroMessenger/6.5.3 NetType/WIFI Language/en", | |
"Accept-Language": "en-us", | |
}, | |
) | |
print('Response HTTP Status Code: {status_code}'.format( | |
status_code=response.status_code)) | |
return response.json() | |
except requests.exceptions.RequestException: | |
print('HTTP Request failed') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment