2021年4月9日 星期五

Python: 初次使用selenium的兩個問題解法

1.python3爬虫给seleium库所遇到的问题

https://blog.csdn.net/Omann/article/details/105074783


2.selenium.common.exceptions.WebDriverException: Message: Service geckodriver unexpectedly exited. Status code was: -11 - How to fix?

https://stackoverflow.com/questions/53989001/selenium-common-exceptions-webdriverexception-message-service-geckodriver-unex


--

Traceback (most recent call last):

  File "C:\Users\UT\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start

    stdin=PIPE)

  File "C:\Users\UT\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 775, in __init__

    restore_signals, start_new_session)

  File "C:\Users\UT\AppData\Local\Programs\Python\Python37-32\lib\subprocess.py", line 1178, in _execute_child

    startupinfo)

FileNotFoundError: [WinError 2] 系統找不到指定的檔案。


During handling of the above exception, another exception occurred:


Traceback (most recent call last):

  File "<pyshell#1>", line 1, in <module>

    browser = webdriver.Firefox()

  File "C:\Users\UT\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__

    self.service.start()

  File "C:\Users\UT\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start

    os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.