ich würde gerne das asyncio Modul mit einem Socksproxy auf einem lokalen Port verwenden. Nach ein wenig Recherche habe ich die PySocks gefunden, die nach ein paar Korrekturen auch mir Python3 läuft. Ich kann eine Anfrage (synchron) durch den Proxy schicken und erhalte eine Antwort.
Nach viel Recherche habe ich rausgefunden, wo in asyncio die Verbindung zu einem Socket aufgebaut wird und habe dort, probehalber, meinen Socks5 Socket reingepfriemelt:
Der ursprüngliche Code:
Code: Alles auswählen
base_events.py, 396-399:
try:
sock = socket.socket(family=family, type=type, proto=proto)
sock.setblocking(False)
Code: Alles auswählen
base_events.py:
try:
#sock = socket.socket(family=family, type=type, proto=proto)
from . import socks
sock = socks.socksocket()
sock.setproxy(socks.PROXY_TYPE_SOCKS5, "localhost", 9050)
sock.setblocking(False)
Code: Alles auswählen
Future/Task exception was never retrieved
future: Task(<create_connection>)<exception=ProxyConnectionError()>
Traceback (most recent call last):
File "/home/flugplatz89/python/aiohttp/asyncio/socks.py", line 479, in connect
_orig_socket.connect(self, (proxy_addr, proxy_port))
BlockingIOError: [Errno 115] Operation now in progress
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/flugplatz89/python/aiohttp/asyncio/tasks.py", line 300, in _step
result = coro.send(value)
File "/home/flugplatz89/python/aiohttp/asyncio/base_events.py", line 424, in create_connection
raise exceptions[0]
File "/home/flugplatz89/python/aiohttp/asyncio/base_events.py", line 415, in create_connection
yield from self.sock_connect(sock, address)
File "/home/flugplatz89/python/aiohttp/asyncio/futures.py", line 350, in __iter__
return self.result() # May raise too.
File "/home/flugplatz89/python/aiohttp/asyncio/futures.py", line 243, in result
raise self._exception
File "/home/flugplatz89/python/aiohttp/asyncio/selector_events.py", line 297, in _sock_connect
sock.connect(address)
File "/home/flugplatz89/python/aiohttp/asyncio/socks.py", line 489, in connect
raise ProxyConnectionError(msg, error)
asyncio.socks.ProxyConnectionError: Error connecting to SOCKS5 proxy localhost:9050: [Errno 115] Operation now in progress
Vielen Dank für eure Hilfe.