Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. from email.mime.multipart import MIMEMultipart
  2. from email.mime.application import MIMEApplication
  3. import requests
  4.  
  5. related = MIMEMultipart('form-data', '__-----------------------12774362691506035193370')
  6. file_part = MIMEApplication(
  7. open('file', 'rb').read()
  8. )
  9. file_part.add_header('Content-disposition', 'attachment; name="name"; filename="filename"')
  10. file_part.add_header('Content-Type', 'application/octet-stream')
  11. related.attach(file_part)
  12.  
  13. body = related.as_string().split('\n\n', 1)[1]
  14. headers = dict(related.items())
  15. headers['User-Agent'] = 'user-agent'
  16.  
  17. url = 'url'
  18. r = requests.post(url, data=body, headers=headers)
  19. print(r.status_code)
  20. print(r.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement