简体   繁体   English

未创建 Chrome 驱动程序会话 - 硒网络抓取

[英]Chrome driver Session not created - selenium web scraping

I'm doing some web scraping on a js rendered website using python.我正在使用 python 在 js 呈现的网站上进行一些网页抓取。 Here is my code:这是我的代码:

import selenium
url2 = 'https://www.adviserratings.com.au/find-an-adviser/'
driver = webdriver.Chrome()
driver.get(url2)

I've done a lot of research, and most of the similar problems are caused by Chrome diver version or Chrome version.查了很多资料,大部分类似的问题都是Chrome diver版本或者Chrome版本引起的。

I'm pretty sure my chrome driver and chrome version are correct.我很确定我的 chrome 驱动程序和 chrome 版本是正确的。 But it still shows the error message as below:但它仍然显示如下错误信息:

SessionNotCreatedException: Message: session not created
from disconnected: unable to connect to renderer
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.43.600210 
(68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.14393 
x86_64)

It will launch a chrome but unable to open anything, after a few seconds, it will be closed and pop up with error message它将启动一个 chrome 但无法打开任何东西,几秒钟后,它将关闭并弹出错误消息

Here is the screenshot这是屏幕截图

Anyone can help?任何人都可以帮忙吗?

Thanks a lot!非常感谢!

The script below works perfectly fine for me.下面的脚本对我来说非常好。

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from bs4 import BeautifulSoup
import time
from time import sleep
browser = webdriver.Chrome("C:/Utility/chromedriver.exe")

wait = WebDriverWait(browser, 10)

url = 'https://www.nissanusa.com/dealer-locator.html'
browser.get(url)
time.sleep(10) # wait page open complete

html = browser.page_source
soup = BeautifulSoup(html, "html.parser")

data = soup.findAll('div',attrs={'class':'dealers-view'})
for div in data:
    links = div.findAll('a')
    for a in links:
        print(a['href'])

You know you have to put in the path to the chromedriver.exe, right.你知道你必须输入 chromedriver.exe 的路径,对。 Finally, the URL that you posted doesn't really have a lot of material worthy of screen scraping.最后,您发布的 URL 并没有很多值得屏幕抓取的材料。 Usually people try to get lists, or data from tables, or some such thing.通常人们试图从表格中获取列表或数据,或者诸如此类的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM