我正在编写自动回复脚本 pt,但有一个我不太了解的错误代码
对于上下文,这是代码:
from selenium import webdriver
import time
browser = webdriver.Chrome()
browser.get("https://web.whatsapp.com/")
time.sleep(60) #time provided to sign you in on the wb app.
unreadMsgs = browser.find_elements_by_xpath(".//span[span[@class='unread-count icon-meta'] and
not(span[@class='icon icon-meta icon-muted'])]")
if not unreadMsgs:
print("Total unread messages: 0")
else:
print("Total unread messages: ")+ str(len(unreadMsgs))
text = ""
for msg in unreadMsgs:
msg.click()
time.sleep(5)
browser.find_element_by_xpath(".//*[@id='main']/footer/div[1]/div[2]/div/div[2]").send_keys(text)
time.sleep(2)
browser.find_element_by_xpath(".//*[@id='main']/footer/div[1]/button").click()
time.sleep(2)
我正在使用以下模块:
beautifulsoup4==4.6.0
selenium==3.4.3
运行代码时,我得到以下信息:
Traceback (most recent call last):
File "D:\py hw\venv\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "D:\that python thing\lib\subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "D:\that python thing\lib\subprocess.py", line 1178, in _execute_child
startupinfo)
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 "D:/py hw/autoreply.py", line 4, in <module>
browser = webdriver.Chrome()
File "D:\py hw\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
self.service.start()
File "D:\py hw\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
我该如何解决?