[PYTHON] selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

If you get an error like this

    driver = webdriver.Firefox()
  File "/usr/local/pyenv/versions/3.6.8/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/local/pyenv/versions/3.6.8/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/pyenv/versions/3.6.8/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/pyenv/versions/3.6.8/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/pyenv/versions/3.6.8/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

Rewrite like this

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)

Example

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from bs4 import BeautifulSoup
from time import sleep
import pandas as pd

options = Options()
options.headless = True
driver = webdriver.Firefox(options=options)
driver.get('https://nikkei225jp.com/data/karauri.php')
sleep(5)
html = driver.page_source.encode('utf-8')
driver.close()

df_list = pd.read_html(html, header=0)
print(df_list[3].head())

result

Date Nikkei Stock Average Nikkei Stock Average(change)TSE First Section Volume(Million shares)Total short-selling ratio Short-selling ratio(There is price regulation)Short selling ratio(No price restrictions)
0  2020-02-28  21142.96   -805.27          2420     44.5           36.9            7.6
1  2020-02-27  21948.23   -477.96          1811     47.4           40.4            7.0
2  2020-02-26  22426.19   -179.22          1677     46.0           38.1            7.9
3  2020-02-25  22605.41   -781.33          1778     44.5           34.8            9.7
4  2020-02-21  23386.74    -92.41          1155     43.5           37.0            6.5

Recommended Posts

selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
Gaussian process with pymc3