diff --git a/ChangeLos.md b/ChangeLos.md new file mode 100644 index 0000000..2d9f2d4 --- /dev/null +++ b/ChangeLos.md @@ -0,0 +1,2 @@ +#### 更新记录 +2025/01/09:绘制流程图,构思程序实现原理 \ No newline at end of file diff --git a/GetProxy.py b/GetProxy.py new file mode 100644 index 0000000..0778ffd --- /dev/null +++ b/GetProxy.py @@ -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("未获取到代理") diff --git a/IP-test.php b/IP-API/IP-test.php similarity index 100% rename from IP-test.php rename to IP-API/IP-test.php diff --git a/IP-test.py b/IP-API/IP-test.py similarity index 100% rename from IP-test.py rename to IP-API/IP-test.py diff --git a/PyProxy.py b/MainProxy.py similarity index 100% rename from PyProxy.py rename to MainProxy.py diff --git a/ProxyChecker.py b/ProxyChecker.py new file mode 100644 index 0000000..e5c6d54 --- /dev/null +++ b/ProxyChecker.py @@ -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) \ No newline at end of file diff --git a/README.md b/README.md index 85bf907..cc1c184 100644 --- a/README.md +++ b/README.md @@ -19,4 +19,5 @@ 2. 为其他程序提供函数导入 参考`import` -3. 转写为Go程序并打包 \ No newline at end of file +3. 转写为Go程序并打包 +![流程图](./imgs/流程图.png) \ No newline at end of file diff --git a/checker.py b/checker.py deleted file mode 100644 index 24c682b..0000000 --- a/checker.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/imgs/流程图.png b/imgs/流程图.png new file mode 100644 index 0000000..9c93077 Binary files /dev/null and b/imgs/流程图.png differ diff --git a/proxies_list.txt b/proxies_list.txt new file mode 100644 index 0000000..e16d6b9 --- /dev/null +++ b/proxies_list.txt @@ -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 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2268bf8..eae3f57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ PySocks requests -flask \ No newline at end of file +flask +requests[socks] \ No newline at end of file