Created
August 22, 2018 17:16
-
-
Save abhinavlal/60b5ff6e0ba73d7af834f5ed2e1161c1 to your computer and use it in GitHub Desktop.
Code to 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
# coding: utf-8 | |
import requests | |
import csv | |
jar = requests.cookies.RequestsCookieJar() | |
paytm_cookie = 'add-your-cookie' | |
jar.set('connect.sid', paytm-cookie, domain='paytm.com', path='/', secure=True) | |
url = 'https://paytm.com/v1/api/wallet/txnhistory?page_size=100&page_number=' | |
fieldnames = ['imageUrl', 'narration', "payeeId", "payerId", "txnDescription1", "txnStatus", "txnFrom", "txnTo", "txnamount", "txndate", "txntype", "walletOrderId"] | |
with open('paytm-test.csv', 'w') as csvfile: | |
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | |
writer.writeheader() | |
next = True | |
i = 0; | |
while next: | |
r = requests.get(url+str(i), cookies=jar) | |
transactions = r.json() | |
next = transactions['has_next'] | |
i = i+1 | |
print i | |
for txn in transactions['response']: | |
writer.writerow({'imageUrl': txn['imageUrl'], | |
'narration': txn['narration'], | |
'payeeId': txn['payeeId'], | |
'payerId': txn['payerId'], | |
'txnDescription1': txn['txnDescription1'], | |
'txnStatus': txn['txnStatus'], | |
'txnFrom': txn['txnFrom'], | |
'txnTo': txn['txnTo'], | |
'txnamount': txn['txnamount'], | |
'txndate': txn['txndate'], | |
'txntype': txn['txntype'], | |
'walletOrderId': txn['walletOrderId']}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment