Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve proxies with one line of code #17

Open
ghost opened this issue Dec 1, 2020 · 1 comment
Open

Serve proxies with one line of code #17

ghost opened this issue Dec 1, 2020 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@ghost
Copy link

ghost commented Dec 1, 2020

I think the code to get a list of proxies should be as simple as possible. So just make something like proxies = Broker.get_proxies(n). Maybe an optional parameter with the format of the strings.

def getProxies(n: int) -> List[str]:
    '''Return a list of n working proxies
    '''
    async def show(proxies):
        p = []
        while True:
                proxy = await proxies.get()
                if proxy is None: break
                p.append(f'{proxy.host}:{proxy.port}')
        return p
 
    proxies = asyncio.Queue()
    broker = Broker(proxies)
    tasks = asyncio.gather(broker.find(types=['HTTPS'], limit=n), show(proxies))
    loop = asyncio.get_event_loop()
    return loop.run_until_complete(tasks)[1]
@bluet bluet added enhancement New feature or request help wanted Extra attention is needed labels Apr 7, 2021
@bluet
Copy link
Owner

bluet commented Apr 7, 2021

@ajr-dev thanks for your feedback 😃 Would you like to send a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant