Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import datetime
- import os
- token = 'bazofia'
- for a in range(1, 5):
- ri = requests.get('https://www.personal.com.py/mimundo/rest/v1/grupos-facturacion/facturas-digitales?token={}&ordenadoPor=numeroFactura;desc®istros=10&inicio={}&_=1632061768737'.format(token, a))
- invoices = map(lambda x: (x.get('numeroFactura'), x.get('fechaEmision')), ri.json().get('lista'))
- for number, date in invoices:
- dateobj = datetime.datetime.fromtimestamp(int(str(date)[0:10]))
- datestr = dateobj.strftime('%Y%m')
- try:
- os.mkdir('/home/peter/Documents/Contabilidad/PJL/{}'.format(datestr))
- except:
- pass
- url = "https://www.personal.com.py/mimundo/rest/v1/grupos-facturacion/facturas-digitales/FT/{}/exportar?token={}".format(number, token)
- riin = requests.get(url)
- with open('/home/peter/Documents/Contabilidad/PJL/{}/personal_invoice_{}.pdf'.format(datestr, number), 'w') as ff:
- ff.write(riin.content)
Add Comment
Please, Sign In to add comment