update
This commit is contained in:
parent
c6e4e837ec
commit
b118b425d3
2
ChangeLos.md
Normal file
2
ChangeLos.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#### 更新记录
|
||||||
|
2025/01/09:绘制流程图,构思程序实现原理
|
26
GetProxy.py
Normal file
26
GetProxy.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
def get_proxies(token):
|
||||||
|
url = f"http://uu-proxy.com/api/get_proxies?id={token}&size=10&schemes=http,socks4,socks5&support_https=true&restime_within_ms=5000&format=txt2_2"
|
||||||
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status() # 检查请求是否成功
|
||||||
|
proxies = response.text.splitlines() # 将返回的文本按行分割成列表
|
||||||
|
return proxies
|
||||||
|
except requests.RequestException as e:
|
||||||
|
print(f"请求出错: {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
|
def save_proxies_to_file(proxies):
|
||||||
|
with open('proxies_list.txt', 'w', encoding="utf-8") as file:
|
||||||
|
for proxy in proxies:
|
||||||
|
file.write(proxy + '\n')
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
token = "123" # 这里可以替换为实际的token
|
||||||
|
proxies = get_proxies(token)
|
||||||
|
if proxies:
|
||||||
|
save_proxies_to_file(proxies)
|
||||||
|
print("代理已保存至proxies_list.txt")
|
||||||
|
else:
|
||||||
|
print("未获取到代理")
|
42
ProxyChecker.py
Normal file
42
ProxyChecker.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
def read_proxies(file_path):
|
||||||
|
with open(file_path, "r") as file:
|
||||||
|
proxies_list = file.read().strip().split("\n")
|
||||||
|
return proxies_list
|
||||||
|
|
||||||
|
def get(url, proxy):
|
||||||
|
try:
|
||||||
|
# Parse the proxy string
|
||||||
|
proxy_type, ip, port = proxy.split()
|
||||||
|
proxy_url = f"{proxy_type.lower()}://{ip}:{port}"
|
||||||
|
|
||||||
|
# Send proxy requests to the final URL
|
||||||
|
response = requests.get(url, proxies={'http': proxy_url, 'https': proxy_url}, timeout=5)
|
||||||
|
if response.status_code == 200:
|
||||||
|
response_lines = response.text.strip().split("\n")
|
||||||
|
ip_info = {}
|
||||||
|
for line in response_lines:
|
||||||
|
key, value = line.split(": ", 1)
|
||||||
|
ip_info[key] = value
|
||||||
|
|
||||||
|
if ip_info.get('IP地址') == ip_info.get('X-Forwarded-For') == ip_info.get('X-Real-IP') == ip:
|
||||||
|
print(f"Proxy: {proxy} is available.")
|
||||||
|
else:
|
||||||
|
print(f"Proxy: {proxy} is not available.")
|
||||||
|
print(f"IP地址: {ip_info.get('IP地址')}")
|
||||||
|
print(f"X-Forwarded-For: {ip_info.get('X-Forwarded-For')}")
|
||||||
|
print(f"X-Real-IP: {ip_info.get('X-Real-IP')}")
|
||||||
|
else:
|
||||||
|
print(f"Failed to connect with proxy {proxy}. Status code: {response.status_code}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error with proxy {proxy}: {e}")
|
||||||
|
|
||||||
|
def check_proxies(proxies_list, test_url):
|
||||||
|
for proxy in proxies_list:
|
||||||
|
get(test_url, proxy)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
proxies = read_proxies("proxies_list.txt")
|
||||||
|
test_url = "https://test.masonliu.com/api/IP-test.php"
|
||||||
|
check_proxies(proxies, test_url)
|
@ -20,3 +20,4 @@
|
|||||||
2. 为其他程序提供函数导入
|
2. 为其他程序提供函数导入
|
||||||
参考`import`
|
参考`import`
|
||||||
3. 转写为Go程序并打包
|
3. 转写为Go程序并打包
|
||||||
|
![流程图](./imgs/流程图.png)
|
17
checker.py
17
checker.py
@ -1,17 +0,0 @@
|
|||||||
import requests
|
|
||||||
|
|
||||||
proxies_list = open("proxies_list.txt", "r").read().strip().split("n")
|
|
||||||
|
|
||||||
def get(url, proxy):
|
|
||||||
try:
|
|
||||||
# Send proxy requests to the final URL
|
|
||||||
response = requests.get(url, proxies={'http': f"http://{proxy}"}, timeout=30)
|
|
||||||
print(response.status_code, response.text)
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
def check_proxies():
|
|
||||||
proxy = proxies_list.pop()
|
|
||||||
get("http://ident.me/", proxy)
|
|
||||||
|
|
||||||
check_proxies()
|
|
BIN
imgs/流程图.png
Normal file
BIN
imgs/流程图.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 373 KiB |
4
proxies_list.txt
Normal file
4
proxies_list.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
SOCKS4 47.121.141.160 1080
|
||||||
|
HTTP 60.28.59.242 7890
|
||||||
|
SOCKS5 47.92.158.11 7890
|
||||||
|
HTTP 117.24.12.180 8080
|
@ -1,3 +1,4 @@
|
|||||||
PySocks
|
PySocks
|
||||||
requests
|
requests
|
||||||
flask
|
flask
|
||||||
|
requests[socks]
|
Loading…
Reference in New Issue
Block a user