Sfoglia il codice sorgente

Merge pull request #80 from bobobo80/master

增加讯代理获取
J_hao104 8 anni fa
parent
commit
e3b454e2d2
2 ha cambiato i file con 20 aggiunte e 3 eliminazioni
  1. 1 0
      Config.ini
  2. 19 3
      ProxyGetter/getFreeProxy.py

+ 1 - 0
Config.ini

@@ -13,6 +13,7 @@ freeProxySecond = 1
 freeProxyThird  = 1
 freeProxyThird  = 1
 freeProxyFourth = 1
 freeProxyFourth = 1
 freeProxyFifth  = 1
 freeProxyFifth  = 1
+freeProxySixth = 1
 
 
 [HOST]
 [HOST]
 ; API接口配置 http://127.0.0.1:5051
 ; API接口配置 http://127.0.0.1:5051

+ 19 - 3
ProxyGetter/getFreeProxy.py

@@ -127,6 +127,22 @@ class GetFreeProxy(object):
                 port = each_proxy.xpath(".//span[contains(@class, 'port')]/text()")[0]
                 port = each_proxy.xpath(".//span[contains(@class, 'port')]/text()")[0]
                 yield '{}:{}'.format(ip_addr, port)
                 yield '{}:{}'.format(ip_addr, port)
 
 
+    @staticmethod
+    @robustCrawl
+    def freeProxySixth():
+        """
+        抓取讯代理免费proxy http://www.xdaili.cn/ipagent/freeip/getFreeIps?page=1&rows=10
+        :return:
+        """
+        url = 'http://www.xdaili.cn/ipagent/freeip/getFreeIps?page=1&rows=10'
+        request = WebRequest()
+        try:
+            res = request.get(url).json()
+            for row in res['RESULT']['rows']:
+                yield '{}:{}'.format(row['ip'], row['port'])
+        except Exception as e:
+            pass
+
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     gg = GetFreeProxy()
     gg = GetFreeProxy()
@@ -139,8 +155,8 @@ if __name__ == '__main__':
     # for e in gg.freeProxyThird():
     # for e in gg.freeProxyThird():
     #     print e
     #     print e
 
 
-    # for e in gg.freeProxyFourth():
+    # for e in gg.freeProxySixth():
     #     print(e)
     #     print(e)
 
 
-    for e in gg.freeProxyFifth():
-         print(e)
+        # for e in gg.freeProxyFifth():
+        #     print(e)