Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- from lxml import html
- USERNAME = "mar.viera.segovia@gmail.com"
- PASSWORD = "MarMarcos"
- LAST_CHEQUES_FILE = "last_cheques.txt"
- LOGIN_URL = "https://micheque.uy/api/Account/Login"
- URL = "https://micheque.uy/api/ChequeLoan/GetOpenChequeLoans"
- def main():
- session = requests.session()
- headers = dict(referer = LOGIN_URL)
- headers['content-type'] = 'application/json;charset=UTF-8'
- result = session.post(LOGIN_URL, data = '{ Email: "' + USERNAME + '", Password: "' + PASSWORD + '"}', headers = headers)
- result = session.get(URL, headers = dict(referer = URL))
- cheques = json.loads(result.content)
- last_cheques = []
- new_cheques = []
- # Gather from the file the last cheques retrieved
- with open(LAST_CHEQUES_FILE) as f:
- for line in f:
- last_cheques.append(line),
- # Separate the new cheques
- for cheque in cheques:
- if str(cheque['chequeId']) not in last_cheques:
- new_cheques.append(cheque)
- # Clear previous cheques and write the updated list
- file = open(LAST_CHEQUES_FILE, 'w')
- for cheque in cheques:
- file.write(str(cheque['chequeId']))
- file.write('\n')
- file.close()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement