Big refactor/rewrite: dynamic proxies, kill/revive proxies, all internal state stored in redis

This commit is contained in:
2019-11-19 19:00:10 -05:00
parent c735f3cc87
commit ce41aee843
17 changed files with 1938 additions and 747 deletions

31
import_from_broker.py Normal file
View File

@@ -0,0 +1,31 @@
import asyncio
import requests
from proxybroker import Broker, Checker
ARCHITEUTHIS_URL = "http://localhost:5050"
def add_to_architeuthis(name, url):
r = requests.get(ARCHITEUTHIS_URL + "/add_proxy?name=%s&url=%s" % (name, url))
print("ADD %s <%d>" % (name, r.status_code))
async def add(proxies):
while True:
proxy = await proxies.get()
if proxy is None:
break
url = "http://%s:%d" % (proxy.host, proxy.port)
name = "%s_%d" % (proxy.host, proxy.port)
add_to_architeuthis(name, url)
proxies = asyncio.Queue()
broker = Broker(proxies)
tasks = asyncio.gather(broker.find(types=['HTTPS'], limit=300), add(proxies))
loop = asyncio.get_event_loop()
loop.run_until_complete(tasks)