第二行哪裡有錯
driver=webdriver.chrome("desktop\chromedriver")
程式碼
from selenium import webdriver
driver=webdriver.chrome("desktop\chromedriver")
drvier.get("http://www.google.com")
dlement=driver.find_element_by_class_name("gLFyf.gsfi")
element.send_keys("Selenium Python")
錯誤訊息
Traceback (most recent call last):
File "D:\python\find.py", line 2, in <module>
driver=webdriver.chrome("desktop\chromedriver")
TypeError: 'module' object is not callable
driver = webdriver.Chrome('desktop\chromedriver')
Chrome C沒大寫call到其他東西
沒錯的話回應一下,你好像問兩次都沒人看出來蠻慘的。
大寫還是一樣
不是這一個C 前一個
webdriver.Chrome 的 C
你改到後面 chromedriver 的 C 去了
D:\python>python find.py
Traceback (most recent call last):
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\subprocess.py"
, line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\subprocess.py"
, line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系統找不到指定的檔案。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\python\find.py", line 2, in <module>
driver=webdriver.Chrome("desktop\chromedriver")
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executabl
e needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chrome
driver/home
執行寫一大堆 , 看不出來
driver = webdriver.Chrome('C:\Users\Kevin\OneDrive\Desktop\chromedriver')
改成絕對路徑?
看起來是沒抓到你桌面的那個chromedriver.exe
D:\python>python find.py
File "D:\python\find.py", line 2
driver=webdriver.Chrome('C:\Users\Kevin\OneDrive\Desktop\chromedriver')
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in positio
n 2-3: truncated \UXXXXXXXX escape
D:\python>python find.py
File "D:\python\find.py", line 2
driver=webdriver.Chrome('C:\Users\Kevin\OneDrive\Desktop\chromedriver')
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in positio
n 2-3: truncated \UXXXXXXXX escape
driver = webdriver.Chrome('C:\\Users\\Kevin\\OneDrive\\Desktop\\chromedriver')
或
driver = webdriver.Chrome(r"C:\Users\Kevin\OneDrive\Desktop\chromedriver")
D:\python>python find.py
Traceback (most recent call last):
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\subprocess.py"
, line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\subprocess.py"
, line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系統找不到指定的檔案。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\python\find.py", line 2, in <module>
driver = webdriver.Chrome('C:\\Users\\Kevin\\OneDrive\\Desktop\\chromedriver
')
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executabl
e needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chrome
driver/home
D:\python>python find.py
Traceback (most recent call last):
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\subprocess.py"
, line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\subprocess.py"
, line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系統找不到指定的檔案。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\python\find.py", line 2, in <module>
driver = webdriver.Chrome(r"C:\Users\Kevin\OneDrive\Desktop\chromedriver")
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\chrome\webdriver.py", line 73, in __init__
self.service.start()
File "C:\Users\Kevin\AppData\Local\Programs\Python\Python39\lib\site-packages\
selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executabl
e needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chrome
driver/home
driver = webdriver.Chrome(r"C:\Users\Kevin\OneDrive\Desktop\chromedriver.exe")
from selenium import webdriver
driver = webdriver.Chrome(r"C:\Users\Kevin\OneDrive\Desktop\chromedriver.exe")
drvier.get("http://www.google.com")
dlement=driver.find_element_by_class_name("gLFyf.gsfi")
element.send_keys("Selenium Python")
D:\python>python find.py
Traceback (most recent call last):
File "C:\Users\Kevin\AppData\Local\Progrpy", line 72, in start
self.process = subprocess.Popen(cmd, e
File "C:\Users\Kevin\AppData\Local\Progr
self._execute_child(args, executable,
File "C:\Users\Kevin\AppData\Local\Progr
hp, ht, pid, tid = _winapi.CreateProce
FileNotFoundError: [WinError 2] 系統找不到
During handling of the above exception, an
Traceback (most recent call last):
File "D:\python\find.py", line 2, in <mo
rograms\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
謝謝 ! 我改到
driver =webdriver.Chrome("D:\python\chromedriver.exe")
就可以執行了 , 但出現 Chrome正在受到自動軟體的控制
你試試看把chromedrive.exe放到這個project路徑底下
然後driver的路徑改這樣,試試看
driver = webdriver.Chrome()
是貼到上面那樣嗎 ?
謝謝 ! 我改到
driver =webdriver.Chrome("D:\python\chromedriver.exe")
就可以執行了 , 但出現 Chrome正在受到自動軟體的控制
我找網路 https://kknews.cc/zh-tw/code/3bqpyyy.html
還是無法解決
Chrome正在受到自動軟體的控制,應該是正確的
我跑的時候chrome上面也會出現這個提示,我看youtube上的教學也都有這個提示
https://youtu.be/nCYvlciLyiM?t=163
https://youtu.be/WnWQgUerR0c?t=442
我自己在寫的時候是這樣寫:
driver = webdriver.Chrome(executable_path=PATH, options=options)
driver.get(web_url)
給你參考
可能你直接寫路徑,沒指定是給哪個參數(executable_path),導致出錯?
謝謝 ! 我改到
driver =webdriver.Chrome("D:\python\chromedriver.exe")
就可以執行了 , 但出現 Chrome正在受到自動軟體的控制
我找網路 https://kknews.cc/zh-tw/code/3bqpyyy.html
還是無法解決