Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!"C:\Program Files\Python\python.exe"
- # -*- coding:utf-8 -*-
- import urllib.request
- def auth_proxy(request, opener, urlerror_code):
- try:
- response = opener.open(request, timeout=10)
- except urllib.request.HTTPError as err:
- return err.code
- except urllib.request.URLError as err:
- return urlerror_code
- else:
- return response.getcode()
- if __name__ == "__main__":
- urlerror_code = 600
- proxy_list = ['http://121.54.175.94:27787',
- 'http://122.116.238.22:30032',
- 'http://132.148.13.46:53424',
- 'http://132.148.13.46:35807',
- 'http://132.148.3.216:31785',
- 'http://166.62.84.121:52468',
- 'http://166.62.84.121:44147',
- 'http://166.62.83.129:44147',
- 'http://166.62.83.129:30834',
- 'http://166.62.84.121:18984',
- 'http://166.62.84.121:12269',
- 'http://166.62.83.129:12269',
- 'http://166.62.83.129:26232']
- headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36"}
- request = urllib.request.Request("http://www.google.com", headers=headers, proxies=proxy_list)
- good_list = []
- for proxy in proxy_list:
- proxy_handler = urllib.request.ProxyHandler(proxy)
- opener = urllib.request.build_opener(proxy_handler)
- num = auth_proxy(request, opener, urlerror_code)
- if num == 200:
- good_list.append(proxy)
- print(good_list)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement