Selaa lähdekoodia

[update]修改文档

jinghao_wb 9 vuotta sitten
vanhempi
sitoutus
db310f9a84
4 muutettua tiedostoa jossa 31 lisäystä ja 3 poistoa
  1. 9 0
      README.md
  2. 15 2
      Util/utilFunction.py
  3. 1 1
      doc/introduce.md
  4. 6 0
      doc/release_notes.md

+ 9 - 0
README.md

@@ -8,6 +8,15 @@
 [![GitHub contributors](https://img.shields.io/github/contributors/jhao104/proxy_pool.svg)](https://github.com/jhao104/proxy_pool/graphs/contributors)
 [![](https://img.shields.io/badge/language-Python-green.svg)](https://github.com/jhao104/proxy_pool)
 
+    ______                        ______             _
+    | ___ \_                      | ___ \           | |
+    | |_/ / \__ __   __  _ __   _ | |_/ /___   ___  | |
+    |  __/|  _// _ \ \ \/ /| | | ||  __// _ \ / _ \ | |
+    | |   | | | (_) | >  < \ |_| || |  | (_) | (_) || |___
+    \_|   |_|  \___/ /_/\_\ \__  |\_|   \___/ \___/ \_____\
+                           __ / /
+                          /___ /
+
 ##### [介绍文档](https://github.com/jhao104/proxy_pool/blob/master/doc/introduce.md)
 
 * 支持版本: ![](https://img.shields.io/badge/Python-2.x-green.svg) ![](https://img.shields.io/badge/Python-3.x-blue.svg)

+ 15 - 2
Util/utilFunction.py

@@ -67,6 +67,19 @@ def getHtmlTree(url, **kwargs):
     return etree.HTML(html)
 
 
+def tcpConnect(proxy):
+    """
+    TCP 三次握手
+    :param proxy:
+    :return:
+    """
+    from socket import socket, AF_INET, SOCK_STREAM
+    s = socket(AF_INET, SOCK_STREAM)
+    ip, port = proxy.split(':')
+    result = s.connect_ex((ip, int(port)))
+    return True if result == 0 else False
+
+
 # noinspection PyPep8Naming
 def validUsefulProxy(proxy):
     """
@@ -76,10 +89,10 @@ def validUsefulProxy(proxy):
     """
     if isinstance(proxy, bytes):
         proxy = proxy.decode('utf8')
-    proxies = {"https": "https://{proxy}".format(proxy=proxy)}
+    proxies = {"http": "http://{proxy}".format(proxy=proxy)}
     try:
         # 超过20秒的代理就不要了
-        r = requests.get('https://www.baidu.com', proxies=proxies, timeout=20, verify=False)
+        r = requests.get('http://httpbin.org/ip', proxies=proxies, timeout=20, verify=False)
         if r.status_code == 200:
             logger.info('%s is ok' % proxy)
             return True

+ 1 - 1
doc/introduce.md

@@ -1,5 +1,5 @@
 
-代理池介绍
+## 代理池介绍
 
 本项目通过爬虫方式持续抓取代理网站公布的免费代理IP,实时校验,维护部分可以使用的代理,并通过api的形式提供外部使用。
 

+ 6 - 0
doc/release_notes.md

@@ -0,0 +1,6 @@
+## Release Notes
+
+* 1.10
+  1. 第一版;
+  2. 支持PY2/PY3;
+  3. 代理池基本功能;