Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import requests
  2. response = requests.get('<external url', auth=('<username>', '<password>'))
  3. data = response.json()
  4. html = data['list'][0]['attachments'][0]['url']
  5. print (html)
  6. data = requests.get('<API URL to download the attachment>', auth=('<username>', '<password>'), stream=True)
  7. print (data.content)
  8.  
  9. <url to download the binary data>
  10. x00x00x13x00x00x00x00x00x00x00x00x00x00x00x00x00x0fxcbx00x00x1ex00x1ex00xbex07x00x00.xcfx05x00x00x00'
  11.  
  12. import requests
  13. import shutil
  14.  
  15. response = requests.get('<url>', auth=('<username>', '<password>'))
  16. data = response.json()
  17. html = data['list'][0]['attachments'][0]['url']
  18. print (html)
  19. data = requests.get('<url>', auth=('<username>', '<password>'), stream=True)
  20. with open("C:/myfile.docx", 'wb') as f:
  21. data.raw.decode_content = True
  22. shutil.copyfileobj(data.raw, f)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement