国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

WebDriverException:消息:服務/ content / chromedriver意外退出狀態代碼為:-6(使用ChromeDriverGoogle Colab和Selenium)

瀏覽:173日期:2024-05-16 15:57:17
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解決WebDriverException:消息:服務/ content / chromedriver意外退出狀態代碼為:-6(使用ChromeDriverGoogle Colab和Selenium)?

我已經找到了有關為什么我出錯的問題的答案。請安裝chrome-chromedriver,并將其添加到您的路徑變量以及bin目錄中。

這是解決如何在Colab上使用Selenium抓取數據的完整解決方案。使用PhantomJS還有另一種方法,但是Selenium已棄用此API,希望他們在下一次Selenium更新中將其刪除。

# install chromium, its driver, and selenium!apt-get update!apt install chromium-chromedriver!cp /usr/lib/chromium-browser/chromedriver /usr/bin!pip install selenium# set options to be headless, ..from selenium import webdriveroptions = webdriver.ChromeOptions()options.add_argument(’--headless’)options.add_argument(’--no-sandBox’)options.add_argument(’--disable-dev-shm-usage’)# open it, go to a website, and get resultswd = webdriver.Chrome(’chromedriver’,options=options)wd.get('https://www.website.com')print(wd.page_source) # results

這對于想要在Google Colab上而不是在您的本地計算機上抓取數據的任何人都有效。請按相同順序依次執行以下步驟。

您可以在https://colab.research.google.com/drive/1GFJKhpOju_WLAgiVPCzCGTBVGMkyAjtk中找到筆記本。

解決方法

我試圖使用Selenium運行無頭Chrome瀏覽器以從網絡上抓取內容。我使用wget安裝了無頭Chrome,然后將其解壓縮到當前文件夾中。

!wget 'http://chromedriver.storage.googleapis.com/2.25/chromedriver_linux64.zip'!unzip chromedriver_linux64.zip

現在,當我加載驅動程序時

from selenium.webdriver.chrome.options import Optionsimport os# instantiate a chrome options object so you can set the size and headless preferencechrome_options = Options()chrome_options.add_argument('--headless')chrome_options.add_argument('--window-size=1920x1080')chrome_driver = os.getcwd() +'/chromedriver'driver = webdriver.Chrome(chrome_options=chrome_options,executable_path=chrome_driver)

我收到一個錯誤

WebDriverExceptionTraceback (most recent call last)<ipython-input-67-0aeae0cfd891> in <module>()----> 1 driver = webdriver.Chrome(chrome_options=chrome_options,executable_path=chrome_driver) 2 driver.get('https://www.google.com') 3 lucky_button = driver.find_element_by_css_selector('[name=btnI]') 4 lucky_button.click() 5 /usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py in __init__(self,executable_path,port,chrome_options,service_args,desired_capabilities,service_log_path) 60 service_args=service_args,61 log_path=service_log_path)---> 62 self.service.start() 63 64 try: /usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in start(self) 84 count = 0 85 while True: ---> 86 self.assert_process_still_running() 87 if self.is_connectable(): 88 break /usr/local/lib/python3.6/dist-packages/selenium/webdriver/common/service.py in assert_process_still_running(self) 97 raise WebDriverException( 98 ’Service %s unexpectedly exited. Status code was: %s’ ---> 99 % (self.path,return_code)100 )101WebDriverException: Message: Service /content/chromedriver unexpectedly exited. Status code was: -6更新資料

因此,經過一些研究,我嘗試了另一種方法

!apt install chromium-chromedriverimport selenium as seoptions = se.webdriver.ChromeOptions()options.add_argument(’headless’)driver = se.webdriver.Chrome(chrome_options=options)

在Google Colab上,這再次給了我相同的錯誤

WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: -6

標簽: web
相關文章:
主站蜘蛛池模板: 免费一级毛片免费播放 | 欧美高清亚洲欧美一区h | 国产黄色a三级三级三级 | 国产美女毛片 | 国产一区曰韩二区欧美三区 | 中国胖女人一级毛片aaaaa | 欧美专区在线视频 | 一级做a爱过程免费观看 | 九色愉拍自拍 | 丁香伊人五月综合激激激 | 国产视频在线免费观看 | 成人看片黄a毛片 | 成人看片黄a免费看视频 | 操美国女人 | 美女免费黄视频 | 久久久久久久国产精品影院 | 欧美综合在线视频 | 91一区二区在线观看精品 | 亚洲一区二区三区精品国产 | 一区精品视频 | 香蕉香蕉国产片一级一级毛片 | 免费狼人久久香蕉网 | 国产三级在线观看免费 | 久久www视频 | 国产欧美一区二区三区在线 | 69交性视频 | 久久96国产精品久久久 | 99久久99久久久精品久久 | 国产亚洲欧美成人久久片 | 国产一区二区三区成人久久片 | 免费一级欧美大片视频在线 | 91热国内精品永久免费观看 | 大陆老太xxxxxxxxhd| 欧美一级毛片高清视频 | 香港日本韩国三级网站 | 国产高清a毛片在线看 | 欧美成人极品怡红院tv | 久久精品视频亚洲 | 国产成人免费在线视频 | 亚洲欧美日本视频 | 最新国产午夜精品视频成人 |