You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env python3importlogginglogging.basicConfig(level=logging.INFO)
importnodriverasucasyncdefmain():
# Start the nodriverdriver=awaituc.start(
headless=False,
sandbox=False,
browser_executable_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
)
# Navigate to the Instagram accountinstagram_account_url= (
"https://www.instagram.com/therock"
)
print(f"Navigating to {instagram_account_url}")
tab=awaitdriver.get(instagram_account_url)
# Wait for the page to load completelyawaittab.sleep(5) # Adjust the sleep time if necessary# Take a screenshot and save it locallyscreenshot_filename="instagram_screenshot.png"print(f"Taking screenshot and saving as {screenshot_filename}")
awaittab.screenshot(screenshot_filename)
# Close the browserdriver.stop()
print("Browser closed")
if__name__=="__main__":
# Run the asynchronous main functionuc.loop().run_until_complete(main())
It works perfectly when using miniconda but using poetry it breakes when I run poetry run scripts/social/account_screenshot.py
poetry run scripts/social/account_screenshot.py
INFO:nodriver.core.browser:starting
executable :/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
arguments:
--remote-allow-origins=*
--no-first-run
--no-service-autorun
--no-default-browser-check
--homepage=about:blank
--no-pings
--password-store=basic
--disable-infobars
--disable-breakpad
--disable-component-update
--disable-backgrounding-occluded-windows
--disable-renderer-backgrounding
--disable-background-networking
--disable-dev-shm-usage
--disable-features=IsolateOrigins,site-per-process
--disable-session-crashed-bubble
--disable-search-engine-choice-screen
--user-data-dir=/var/folders/k2/7321ff_s2rv1cphl835x1trh0000gn/T/uc_bvxes8sj
--disable-features=IsolateOrigins,site-per-process
--disable-session-crashed-bubble
--no-sandbox
--remote-debugging-host=127.0.0.1
--remote-debugging-port=64616
Traceback (most recent call last):
File "/Users/me/Coding/Projects/github/crawlers/scripts/social/account_screenshot.py", line 49, in<module>uc.loop().run_until_complete(main())
File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
returnfuture.result()
^^^^^^^^^^^^^^^
File "/Users/me/Coding/Projects/github/crawlers/scripts/social/account_screenshot.py", line 12, in main
driver = await uc.start(
^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/crawlers-pbtkaTlW-py3.12/lib/python3.12/site-packages/nodriver/core/util.py", line 96, in start
return await Browser.create(config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/me/Library/Caches/pypoetry/virtualenvs/crawlers-pbtkaTlW-py3.12/lib/python3.12/site-packages/nodriver/core/browser.py", line 91, in create
await instance.start()
File "/Users/me/Library/Caches/pypoetry/virtualenvs/crawlers-pbtkaTlW-py3.12/lib/python3.12/site-packages/nodriver/core/browser.py", line 352, in start
raise Exception(
Exception:
---------------------
Failed to connect to browser
---------------------
One of the causes could be when you are running as root.
In that case you need to pass no_sandbox=True
Exception ignored in atexit callback: <function deconstruct_browser at 0x10d6c8860>
Traceback (most recent call last):
File "/Users/me/Library/Caches/pypoetry/virtualenvs/crawlers-pbtkaTlW-py3.12/lib/python3.12/site-packages/nodriver/core/util.py", line 146, in deconstruct_browser
_.stop()
File "/Users/me/Library/Caches/pypoetry/virtualenvs/crawlers-pbtkaTlW-py3.12/lib/python3.12/site-packages/nodriver/core/browser.py", line 558, in stop
asyncio.get_event_loop().create_task(self.connection.aclose())
^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'aclose'
Does someone has an idea to fix this? The browser is opening but looks like the script can't connect to it.
The text was updated successfully, but these errors were encountered:
I am running a simple script
It works perfectly when using miniconda but using poetry it breakes when I run
poetry run scripts/social/account_screenshot.py
Does someone has an idea to fix this? The browser is opening but looks like the script can't connect to it.
The text was updated successfully, but these errors were encountered: