在github上发现一个自动更新的http代理的仓库fate0
下面python脚本实现自动获取并添加到proxychains.conf配置文件中
[getHttp.py]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# AUTHOR: Mangolins
# Description:
# 自动获取http代理,并添加到proxychains.conf中
#Usage:
# python3 gethttp.py
import requests
import urllib3
import json
import sys
import shutil
def get_socks5(proxychains_path):
"""
get socks from http://proxylist.fatezero.org/proxy.list.
proxychains_path: str -> the path of proxycahins-ng configuation file.
***suggestion: enable round_robin_chain****
#strict_chain
#dynamic_chain
#round_robin_chain
random_chain
chain_len = 2
"""
proxychains_file = proxychains_path
url="http://proxylist.fatezero.org/proxy.list"
headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
}
urllib3.disable_warnings()
try:
response = requests.get(url=url,headers=headers,verify=False,timeout=10)
except Exception as e:
print(e)
exit()
if response.status_code == 200 :
proxy_list = response.text.splitlines()
socks_list="\n\n# socks5 list from http://proxylist.fatezero.org/proxy.list\n"
for item in proxy_list:
item_dict = json.loads(item)
if "http" == item_dict['type'] and "high_anonymous" == item_dict['anonymity']:
try:
httpurl='http://'+item_dict['host'] + ':' + str(item_dict['port'])
httpresponse = requests.get(url=httpurl,verify=False,timeout=2)
if httpresponse.status_code == 200:
socks_item = item_dict['type'] +"\t" + item_dict['host'] + "\t" + str(item_dict['port'])+"\n"
socks_list += socks_item
except Exception as e:
print(e)
print(socks_list)
with open(proxychains_file,"a+") as f:
f.write(socks_list)
if __name__ == '__main__':
shutil.copy("/etc/proxychains.conf.bak","/etc/proxychains.conf")
if sys.argv.__len__() == 1:
get_socks5("/etc/proxychains.conf")
else:
get_socks5(sys.argv[1])</pre>
执行脚本后,代理效果很差,基本上都不能用。
# python3 getHttp.py
HTTPConnectionPool(host='3.95.126.46', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693a0cf40>, 'Connection to 3.95.126.46 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.197.194', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693989970>, 'Connection to 51.222.197.194 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='82.223.21.37', port=80): Read timed out. (read timeout=2)
HTTPConnectionPool(host='23.91.96.251', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693a0cfd0>, 'Connection to 23.91.96.251 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='80.48.119.28', port=8080): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693992580>, 'Connection to 80.48.119.28 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='212.96.121.90', port=8080): Read timed out. (read timeout=2)
HTTPConnectionPool(host='52.78.172.171', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f66939a6610>, 'Connection to 52.78.172.171 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='129.204.182.65', port=9999): Read timed out. (read timeout=2)
HTTPConnectionPool(host='51.222.197.146', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693989370>, 'Connection to 51.222.197.146 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.197.157', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693989400>, 'Connection to 51.222.197.157 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.197.192', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693a0c820>, 'Connection to 51.222.197.192 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='185.235.41.85', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f66939a6af0>, 'Connection to 185.235.41.85 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='175.110.204.95', port=8080): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f66939321f0>, 'Connection to 175.110.204.95 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='103.87.170.80', port=58248): Read timed out. (read timeout=2)
HTTPConnectionPool(host='104.43.230.151', port=3128): Read timed out. (read timeout=2)
HTTPConnectionPool(host='103.83.156.225', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f66939895e0>, 'Connection to 103.83.156.225 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='92.204.129.161', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693992e80>, 'Connection to 92.204.129.161 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='143.198.57.246', port=3128): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f66939320a0>, 'Connection to 143.198.57.246 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.220.236', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693932ac0>, 'Connection to 51.222.220.236 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.220.231', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693932700>, 'Connection to 51.222.220.231 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='194.233.64.34', port=80): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693992250>, 'Connection to 194.233.64.34 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='61.37.223.152', port=8080): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693992490>, 'Connection to 61.37.223.152 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='176.56.107.101', port=32161): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693989fd0>, 'Connection to 176.56.107.101 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.220.247', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693a0cdc0>, 'Connection to 51.222.220.247 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.67.214', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693a0c790>, 'Connection to 51.222.67.214 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='51.222.220.241', port=32769): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f669393a1c0>, 'Connection to 51.222.220.241 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='157.230.103.189', port=41208): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6693a0ca00>, 'Connection to 157.230.103.189 timed out. (connect timeout=2)'))
HTTPConnectionPool(host='186.126.51.29', port=10809): Read timed out. (read timeout=2)
# socks5 list from http://proxylist.fatezero.org/proxy.list
http 3.211.17.212 80
http 18.204.234.136 80
http 18.210.77.4 80
http 3.224.69.117 80
http 3.219.153.200 80
http 194.71.227.187 8060
# proxychains4 curl cip.cc
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.14-git-41-g092d704
[proxychains] Random chain ... 3.211.17.212:80 ... 18.204.234.136:80 <--denied
[proxychains] Random chain ... 194.71.227.187:8060 ... 3.219.153.200:80 ... 122.51.157.137:80 <--socket error or timeout!
[proxychains] Random chain ... 3.211.17.212:80 ... 3.219.153.200:80 <--denied
[proxychains] Random chain ... 194.71.227.187:8060 ... 3.211.17.212:80 ... 122.51.162.249:80 <--socket error or timeout!
curl: (7) Couldn't connect to server
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区留言。