MCPcopy Create free account
hub / github.com/DVampire/FinAgent / get_us_free_proxy

Function get_us_free_proxy

finagent/utils/get_proxy.py:79–114  ·  view source on GitHub ↗
(pages=10)

Source from the content-addressed store, hash-verified

77
78
79def get_us_free_proxy(pages=10):
80 url = "https://openproxy.space/list/http"
81 headers = {
82 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'}
83 response = requests.get(url, headers=headers)
84 print(response.text)
85 exit()
86
87 if response.status_code != 200:
88 print("Connection Error. Please make sure that your computer now have the access to Google.com")
89 res = etree.HTML(response.text)
90 http_type = "HTTP"
91 proxies_list = []
92
93 scripts = res.xpath("//script")
94 content = scripts[3].xpath(".//text()")
95 pattern = re.compile('LIST",data:(.+),added:')
96 result_list = pattern.findall(content[0])
97 result_list = result_list[0].strip("[{").strip("}]").split("},{")
98
99 for result in result_list:
100 pattern = re.compile('\[(.+)\]')
101 result = pattern.findall(result)
102 result = result[0].split(",")
103 result = [r.strip("\"") for r in result]
104 for ip in result:
105 proxies_list.append(
106 {http_type: ip}
107 )
108 total = pages * 15
109 proxies_list = proxies_list[:total]
110 can_use = check_us_ips(proxies_list)
111 print(f'Get proxy ips: {len(proxies_list)}.')
112 print(f'Usable proxy ips: {len(can_use)}.')
113
114 return can_use
115
116
117class Kuaidaili:

Callers 1

_update_proxyMethod · 0.90

Calls 1

check_us_ipsFunction · 0.85

Tested by

no test coverage detected