Guest User

Untitled

a guest
Jan 18th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import requests
  2. import json
  3.  
  4. url = 'https://v2.convertapi.com/convert/pdf/to/jpg?Secret=******' # Hidden
  5. headers = {'content-type': 'application/json'}
  6. payload = {
  7. 'Parameters': [
  8. {
  9. 'Name': 'File',
  10. 'FileValue': {
  11. 'Url': 'to be populated'
  12. }
  13. },
  14. {
  15. 'Name': 'StoreFile',
  16. 'Value': 'true'
  17. }
  18. ]
  19. }
  20.  
  21. a = ['https://www.bachmann.com/fileadmin/02_Produkte/03_Anschlussfelder/CONI/Downloads/CONI_3-4-6-way_Mounting_instructions_REV05.pdf','test2.jpg','test3.jpeg','test4.png','test4.exe']
  22.  
  23. for x in a:
  24.  
  25. if x[-3:] == 'pdf':
  26. payload['Parameters'][0]['FileValue']['Url'] = x
  27. response = requests.post(url, data=json.dumps(payload), headers=headers)
  28. print(response)
  29.  
  30. elif x[-3:] == 'jpg' or x[-3:] == 'png' or x[-4:] == 'jpeg':
  31. print('thats an image, nothing to do here')
Add Comment
Please, Sign In to add comment