Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- f = open("CheckedProxies.txt", "w")
- f.close();
- filepath = 'Proxies.txt'
- with open(filepath) as fp:
- for cnt, line in enumerate(fp):
- try:
- # try:
- proxies = {
- 'http': 'http://{}'.format(line.rstrip()),
- 'https': 'http://{}'.format(line.rstrip()),
- }
- headers = {
- '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',
- }
- # Create the session and set the proxies.
- s = requests.Session()
- s.proxies = proxies
- # Make the HTTP request through the session.
- r = s.get('http://www.showmemyip.com/', headers=headers, proxies=proxies)
- # Check if the proxy was indeed used (the text should contain the proxy IP).
- if '<title>Show Me My IP!' in r.text:
- w = open("CheckedProxies.txt", "a")
- w.write(line);
- except:
- pass
- # print(line)
- # except:
- # print("Failure")
- # pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement