1

I write a code in python to scrape some data from a web site using selenium. this code completely work when i run it in system command line . But when i run it from xampp command line it give error and show this message

Traceback (most recent call last): File "C:\Users\Marajul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start self.process = subprocess.Popen(cmd, env=self.env, File "C:\Users\Marajul\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in init self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Users\Marajul\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\xampp\htdocs\Dairy\API\toph\python\a.py", line 16, in driver = Chrome(webdriver) File "C:\Users\Marajul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 73, in init self.service.start() File "C:\Users\Marajul\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: 'chromedriver3.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

from selenium.webdriver import Chrome
import pandas as pd
import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  passwd="",
  database="dairy"
)

mycursor = mydb.cursor()

webdriver = 'chromedriver3.exe'

driver = Chrome(webdriver)
cnt=0

while 1:
    page_nb=(str)(cnt);
    url = "https://toph.co/submissions/filter?author=590d7d60de14194eb555201c&start="+page_nb+"&verdict="
    cnt=cnt+64
    driver.get(url)
    quotes = driver.find_elements_by_class_name("syncer")
    if(len(quotes)==0):
        break
    for quote in quotes:
        row=quote.find_elements_by_tag_name("td")
        link=row[2].find_elements_by_tag_name('a')
        time1=row[3].find_elements_by_class_name('timestamp')
        time=time1[0].get_attribute('data-time')
        urlp=""
        if(link):
            urlp=link[0].get_attribute('href')
        sql1="SELECT * FROM submission WHERE id=%s AND oj='toph'"
        val1 = (row[0].text,)
        mycursor.execute(sql1,val1)
        myresult = mycursor.fetchall()
        if(len(myresult)==0):
            sql="INSERT INTO submission (id,dt,link,name,ver,oj) VALUES (%s,%s,%s,%s,%s,'toph')"
            val=(row[0].text,time,urlp,row[2].text,row[7].text)
            mycursor.execute(sql, val)
            mydb.commit()

print("successfull")
driver.close()

i am not expert in python so please help me to fix this problem :)

1
  • Don't post image of text. Post error message as plain text Commented Jan 9, 2020 at 9:14

2 Answers 2

1

Your problem is common "not in PATH" type of problem which is clearly indicated by the error message:

Message: 'chromedriver3.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

And the solution is to either use absolute path to the binary (if you can specify that) or to edit your global env PATH variable and add the location of that binary to it.

Sign up to request clarification or add additional context in comments.

1 Comment

webdriver = 'C:/xampp/htdocs/Dairy/API/toph/python/chromedriver3.exe' use this line instade of webdriver = 'chromedriver3.exe'
1

I have faced a similar issue, it's looking to be this error is generic to windows, after setting shell=True in subprocess.py I able to resolve it.

1 Comment

Where exactly did you set shell=True to make this work? It's been driving me crazy!!!

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.