Closed juanfrilla closed 1 year ago
differ the port with port
arg. because each port is singleton
actually, incognito_tab is Environmentally isolated
, so you can learn to use asyncio.create_task for a real coroutine usage
thanks @ClericPy , so If I put a different port for every AsyncChromeDaemon it should work
yes. host+port is singleton.
Thanks, I created a method :
def find_free_port(self):
# Create a temporary socket to find a free port.
temp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
temp_socket.bind(('localhost', 0)) # Bind to any available local address and port 0.
_, port = temp_socket.getsockname() # Get the assigned port.
temp_socket.close() # Close the temporary socket.
return port
And then:
async with AsyncChromeDaemon(
headless=True,
proxy=proxy,
port = self.find_free_port(),
chrome_path=chrome_path,
user_agent=self._headers["User-Agent"],
) as browser:
async with browser.incognito_tab(proxyServer=proxy) as tab:
await tab.goto(self.origin + "/document/" + doc_id, timeout=60000)
result = await tab.wait_tag("#head", max_wait_time=60)
html = await tab.html
cookies = await tab.get_cookies_dict()
I'm running multiple like this:
But I'm receiving this error: