zbeucler

prnt.sc Scrapper Draft

May 1st, 2020
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. import urllib.request
  2.  
  3. #url w img ==> https://prnt.sc/gh5555
  4. #url w/out img ==> https://prnt.sc/12abce
  5.  
  6. # Request with Header Data to send User-Agent header
  7. url = 'https://prnt.sc/12abce'
  8.  
  9. # gets past servers programmmic access ban
  10. headers = {}
  11. headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17'
  12. #headers['Content-Type'] = 'application/json'
  13.  
  14. #requesting the html
  15. request = urllib.request.Request(url, headers=headers)
  16. resp = urllib.request.urlopen(request)
  17.  
  18. #copies the html and converts response from bytes to a string
  19. byteResp = resp.read()
  20. dataStr = str(byteResp, 'utf-8')
  21.  
  22. #prints the html as a string
  23. print(dataStr)
Add Comment
Please, Sign In to add comment