使用Python爬取Proxy代理伺服器

安裝

pip install git+https://github.com/CharlesPikachu/FreeProxy.git@master

單線程

from FreeProxy import ProxyTool
pt = ProxyTool.ProxyTool()
proxies = pt.getProxy(num_proxies=2, max_tries=5)
print(proxies)
#num_proxies為Proxy數量

多線程

import time
import threading
from FreeProxy import ProxyTool


PROXIES = []
pt = ProxyTool.ProxyTool()
num_threadings = 3


def getProxy(num, max_tries):
global PROXIES
PROXIES += pt.getProxy(num, max_tries)


for i in range(num_threadings):
t = threading.Thread(target=getProxy, args=(1, 5))
time.sleep(0.1)
t.start()
t.join()

Machine Learning / Deep Learning / Python / Flutter cakeresume.com/yanwei-liu

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store