Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import json
- url = 'https://v2.convertapi.com/convert/pdf/to/jpg?Secret=******' # Hidden
- headers = {'content-type': 'application/json'}
- payload = {
- 'Parameters': [
- {
- 'Name': 'File',
- 'FileValue': {
- 'Url': 'to be populated'
- }
- },
- {
- 'Name': 'StoreFile',
- 'Value': 'true'
- }
- ]
- }
- 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']
- for x in a:
- if x[-3:] == 'pdf':
- payload['Parameters'][0]['FileValue']['Url'] = x
- response = requests.post(url, data=json.dumps(payload), headers=headers)
- print(response)
- elif x[-3:] == 'jpg' or x[-3:] == 'png' or x[-4:] == 'jpeg':
- print('thats an image, nothing to do here')
Add Comment
Please, Sign In to add comment