Advertisement
Guest User

Untitled

a guest
Aug 27th, 2018
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import requests
  2.  
  3. f = open("CheckedProxies.txt", "w")
  4. f.close();
  5. filepath = 'Proxies.txt'
  6. with open(filepath) as fp:
  7. for cnt, line in enumerate(fp):
  8. try:
  9. # try:
  10.  
  11. proxies = {
  12. 'http': 'http://{}'.format(line.rstrip()),
  13. 'https': 'http://{}'.format(line.rstrip()),
  14. }
  15. headers = {
  16. 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36',
  17. }
  18.  
  19. # Create the session and set the proxies.
  20. s = requests.Session()
  21. s.proxies = proxies
  22.  
  23. # Make the HTTP request through the session.
  24. r = s.get('http://www.showmemyip.com/', headers=headers, proxies=proxies)
  25.  
  26. # Check if the proxy was indeed used (the text should contain the proxy IP).
  27. if '<title>Show Me My IP!' in r.text:
  28. w = open("CheckedProxies.txt", "a")
  29. w.write(line);
  30. except:
  31. pass
  32.  
  33. # print(line)
  34. # except:
  35. # print("Failure")
  36. # pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement