Forums

How to use webbot from PythonAnywhere ?

Hello there,

I'm pretty new with Python.

I would like to run python script using the webbot librabry : → https://webbot.readthedocs.io/en/latest/

This is a simple script that go to a website, connect to it and refresh every 10min.

Here's some errors from the console :

File "/home/arthurn/.local/lib/python3.7/site-packages/webbot/webbot.py", line 52, in __init__                                                                                                                 
    self.driver = webdriver.Chrome(executable_path=driverpath , chrome_options=options)                                                                                                                          
File "/usr/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__                                                                                                           
    desired_capabilities=desired_capabilities)                                                                                                                                                                   
File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__                                                                                                           
    self.start_session(desired_capabilities, browser_profile)                                                                                                                                                    
File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session                                                                                                     
    response = self.execute(Command.NEW_SESSION, capabilities)                                                                                                                                                   
File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute                                                                                                           
    self.error_handler.check_response(response)                                                                                                                                                                  
File "/usr/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response                                                                                                 
    raise exception_class(message, screen, stacktrace)                                                                                                                                                           
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist                                                                                                     
  (Driver info: chromedriver=2.39.562737 (dba483cee6a5f15e2e2d73df16968ab10b38a2bf),platform=Linux 4.4.0-1100-aws x86_64)

Thank you for your help.

There are two problems: 1. You need your account to be upgraded to the new virtualization to run chrome. I can do it for you now. 2. Consoles are ephemeral by design. You need another solution to keep your script live. See https://help.pythonanywhere.com/pages/AlwaysOnTasks/

[deleted]

@streamearn You already have Chrome.

To use it, you'll need to upgrade Selenium for your account -- for example, if you're using Python 3.7, run this in Bash:

pip3.7 install --user --upgrade selenium

...and then you can run Selenium with Chrome using code like this:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

try:
    browser.get("https://www.google.com")
    print("Page title was '{}'".format(browser.title))

finally:
    browser.quit()