How can I fix the errors in this code? (Answered!)

How can I fix these errors?
Repl link:

from selenium import webdriver
import requests
from bs4 import BeautifulSoup
webpage = r"" # edit me
userprompt = input("Enter prompt here:\n")
searchterm = userprompt # edit me

driver = webdriver.Chrome()

sbox = driver.find_element_by_class_name("textarea")

submit = driver.find_element_by_class_name("button")

text = driver.find_element_by_class_name("p")
Traceback (most recent call last):
  File "", line 8, in <module>
    driver = webdriver.Chrome()
  File "/home/runner/OpenAIScrape/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/", line 81, in __init__
  File "/home/runner/OpenAIScrape/venv/lib/python3.8/site-packages/selenium/webdriver/chromium/", line 103, in __init__
  File "/home/runner/OpenAIScrape/venv/lib/python3.8/site-packages/selenium/webdriver/common/", line 106, in start
  File "/home/runner/OpenAIScrape/venv/lib/python3.8/site-packages/selenium/webdriver/common/", line 119, in assert_process_still_running
    raise WebDriverException(f"Service {self.path} unexpectedly exited. Status code was: {return_code}")
selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

Hello @MiloCat

The error message you provided suggests that the Chrome driver (chromedriver) is not running. This is likely due to the fact that the Chrome driver executable is not in the system’s PATH environment variable, or it is not installed on the system.

You can fix this issue by:

After that you need to give the path of chrome driver to the driver variable by using webdriver.Chrome(path_of_chrome_driver)

Also, the URL you are trying to scrape is not a website, it’s the endpoint for OpenAI’s GPT-3 model. If you want to scrape data from a website, you should use a valid URL.

let me know if this works

hope it helps ! :slight_smile:

1 Like

@bil0009 I have chrome installed on my computer (Chrome OS). I am trying to run this in Also I am using because I want to access ChatGPT through code because I do not have an API key. The textarea input is where you would normally type text and the p is because ChatGPT responds in a <p>. Also how would I add this?

1 Like

Hey there, MiloCat :slight_smile: it’s bigminiboss! While I’m not very good at selenium, I would like to point out that using proxies are against the ToS, I believe.

  1. Use the Service to create a proxy with the purpose of circumventing any firewall or other access control measure;

This would not be true were you not accessing chatgpt which I believe does not have an API. Instead, try using openAi’s Davinci API or some other model :stuck_out_tongue:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.