decl_upload.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. '''
  2. Created on May 28, 2020
  3. @author: vnc-console
  4. '''
  5. # -*- coding: utf-8
  6. import requests
  7. url1 = 'https://decl.anaf.mfinante.gov.ro/WAS6DUS/welcome.do'
  8. url2 = 'https://decl.anaf.mfinante.gov.ro/WAS6DUS/displayFile.do'
  9. header = {
  10. 'Host': "decl.anaf.mfinante.gov.ro",
  11. 'Connection': "keep-alive",
  12. 'Cache-Control': "max-age=0",
  13. 'Upgrade-Insecure-Requests': "1",
  14. 'Origin': "https://decl.anaf.mfinante.gov.ro",
  15. 'Content-Type': "multipart/form-data; boundary=----WebKitFormBoundaryQ8Yib3wqfhoOsOEA",
  16. 'Accept': "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
  17. 'Sec-Fetch-Site': "same-origin",
  18. 'Sec-Fetch-Mode': "navigate",
  19. 'Sec-Fetch-User': "?1",
  20. 'Sec-Fetch-Dest': "document",
  21. 'Referer': "https://decl.anaf.mfinante.gov.ro/WAS6DUS/welcome.do",
  22. 'Accept-Encoding': "gzip, deflate, br",
  23. 'Accept-Language': "en-US,en;q=0.9,ro;q=0.8",
  24. 'Cookie': "LastMRH_Session=cdf388d7; TIN=271000; F5_ST=1z1z1z1590666983z-1; MRHSession=b29432ff35ab290fde9df15ecdf388d7; JSESSIONID=0001nh5KSBj-cmJ3nJMdIAAJko8:-170BNG6"
  25. }
  26. file = {'submit': open('D39416_RO18123758_2020_04-semnat.pdf', 'rb')}
  27. payload = {'D39416_RO18123758_2020_04-semnat.pdf': 'D39416_RO18123758_2020_04-semnat.pdf'}
  28. cookies = dict(MRHSession='1d00ce0f72837b21a0d9f32259bd2d6c',
  29. JSESSIONID='0001THZF39po9P90AY9MvPb9vPQ:2J0BPR7CLJ',
  30. F5_ST='1z1z1z1590684057z-1',
  31. TIN='288000',
  32. LastMRH_Session='59bd2d6c')
  33. # r1 = requests.get(url1, data=file)
  34. r2 = requests.post(url2, data=file, cookies=cookies, headers=header)
  35. # print(r1.status_code, r1.text)
  36. print(r2.text)
  37. # with open('resp.txt', 'w') as resp:
  38. # resp.write(r.text)