0

I'm in the proccess of completing the final project for CS50P and I want to use Selenium to scrape data from web (seems to be called dynamic content, which is why I saw I couldn't use requests). Note: I'm using VS studio in the cloud via the cs50.dev

Selenium is installed via pip install.

I think there's a few problems with the chrome driver:

  1. I don't have the right version. My chrome version is Version 129.0.6668.71 yet I can only find Version 129.0.6668.70 online to download. Does the version have to match correctly? If so, how does one find the right chrome driver when the official website does not have it available to download?

  2. If "1" is not an issue, well, I simply put the chromedriver.exe into the project folder (check picture below):

enter image description here

Yet, when I try to run this code:

from selenium import webdriver
driver = webdriver.Chrome()

which should simply open a chrome tab, I'm getting an error message as follows:

enter image description here

Any ideas as to how I can go about this?

Here's the full window view: enter image description here

Thanks.

I tried to do this even locally in VS Code. While I get no error, the chrome tab doesn't open at all when I run the code.

14
  • 1) Only major version has to match. So you're good. V29 for Chrome and Chromedriver. 2) Looks like the driver crashed. You have "chromedriver.exe" in your screenshot of the project... I think that's for Windows, but the exception you show is for Linux chromedriver. (seems like the built-in driver manager downloaded that) What OS are you running? Try running chromedriver listed in your exception to see what sort of errors it is throwing. Commented Oct 1, 2024 at 17:19
  • Also check to be sure you've added all Selenium's dependencies/libs to your project. Commented Oct 1, 2024 at 17:26
  • Hi, Thanks for the reply. So I ran downloaded the linux driver and placed it in the folder instead of the windows version. Then I ran the exception listed in the terminal, and this is what I get: /home/ubuntu/.cache/selenium/chromedriver/linux64/129.0.6668.70/chromedriver: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory Commented Oct 1, 2024 at 17:57
  • as is, selenium will automatically download and run the correct versions (driver and browser) You won't need to add chromedriver to your project. You're receiving an error that implies that the driver crashed. If you manually run that driver (from the path shown in your exception) it should give you more details on why it crashed. Probably permissions issue or missing dependencies... or Chrome browser isn't working or hasn't been run yet. You should also try to launch Chrome and see if that's working. Commented Oct 1, 2024 at 18:06
  • 1
    I guess so. The only tradeoff there would be that I wouldn't necessarily be able to submit the final project via their command-line tool, but I'll find a workaround to that. Nevertheless, thank you for the clarification! Commented Oct 1, 2024 at 19:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.