Proxybroker IndexError
<p>I'm trying to use the python package proxybroker.<br>
I tried to use one of the examples mentioned here. I just copied the following example to run locally:</p>

<blockquote>
<pre><code>import asyncio from proxybroker import Broker


async def save(proxies, filename):
    """Save proxies to a file."""
    with open(filename, 'w') as f:
        while True:
            proxy = await proxies.get()
            if proxy is None:
                break
            proto = 'https' if 'HTTPS' in proxy.types else 'http'
            row = '%s://%s:%d\n' % (proto, proxy.host, proxy.port)
            f.write(row)


def main():
    proxies = asyncio.Queue()
    broker = Broker(proxies)
    tasks = asyncio.gather(broker.find(types=['HTTP', 'HTTPS'], limit=10),
                           save(proxies, filename='proxies.txt'))
    loop = asyncio.get_event_loop()
    loop.run_until_complete(tasks)


if __name__ == '__main__':
    main()</code></pre>
</blockquote>

<p>When I try to run the code the following error is thrown together with some deprecation warnings:</p>

<blockquote>
<pre><code>/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning)
/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/aiohttp/client.py:494:
DeprecationWarning: Use async with instead   warnings.warn("Use async
with instead", DeprecationWarning) https://getproxy.net/en/ is failed.
Error: ClientOSError(101, 'Cannot connect to host getproxy.net:443
ssl:True [Can not connect to getproxy.net:443 [Network is
unreachable]]'); https://getproxy.net/en/ is failed. Error:
ClientOSError(101, 'Cannot connect to host getproxy.net:443 ssl:True
[Can not connect to getproxy.net:443 [Network is unreachable]]');
https://getproxy.net/en/ is failed. Error: ClientOSError(101, 'Cannot
connect to host getproxy.net:443 ssl:True [Can not connect to
getproxy.net:443 [Network is unreachable]]'); Traceback (most recent
call last):   File
"/home/sebastian/PycharmProjects/testing/test/test_prox.py", line 27,
in 
    main()   File "/home/sebastian/PycharmProjects/testing/test/test_prox.py", line 23,
in main
    loop.run_until_complete(tasks)   File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in
run_until_complete
    return future.result()   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception   File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)   File "/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/proxybroker/api.py",
line 108, in find
    await self._run(self._checker.check_judges(), action)   File "/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/proxybroker/api.py",
line 114, in _run
    await tasks   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception   File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)   File "/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/proxybroker/checker.py",
line 26, in check_judges
    await asyncio.gather(*[j.check() for j in self._judges])   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
    yield self  # This tells Task to wait for completion.   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
    future.result()   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception   File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)   File "/home/sebastian/PycharmProjects/STW/venv/lib/python3.5/site-packages/proxybroker/judge.py",
line 82, in check
    j=self, code=resp.status, page=page[0], IndexError: string index out of range</code></pre>
</blockquote>

<p>I use python3.5.2 and the up to date versions of proxybroker (0.1.4) aiohttp (1.0.2) asyncio (3.4.3).</p>

<p>I'm not sure what causes the error as I did not change the code example and as far as I know I have installed all dependencies. Can anyone help me and tell me what I am doing wrong and even better how to do it right?</p>

<p><strong>EDIT</strong><br>
A quick workaround for the issue is to change the line where the error occurs. That line is only for logging an error, thus the change should not do any harm.
For this workaround - not a solution -  I added an additional check in the judge.py in line 79 where the exception was raised before. 
Locally I changed  it to:</p>

<pre><code>        if isinstance(page, type(list())) or isinstance(page, type(dict())):
            log.error(('{j} is failed. HTTP status code: {code}; '
                       'Real IP on page: {ip}; Version: {word}; '
                       'Response: {page}').format(
                j=self, code=resp.status, page=page[0],
                ip=(get_my_ip() in page), word=(rv in page)))
        else:
            log.error(('{j} is failed. HTTP status code: {code}; '
                       'Real IP on page: {ip}; Version: {word}; '
                       'Response: {page}').format(
                      j=self, code=resp.status, page=page,
                      ip=(get_my_ip() in page), word=(rv in page)))
</code></pre>

<p>That way I can use proxybroker again. The issue is filed on gihub with <a href="https://github.com/constverum/ProxyBroker/issues/23" rel="nofollow">proxybroker</a>.</p>

<p>Deprecation warnings are harmless (at least unless I'll remove this kind of backward compatibility).</p>

<p>The error just says that <code>getproxy.net</code> is not available -- this is your main problem.</p>

python asynchronous python-3.5 python-asyncio aiohttp