南京市建筑工程网站,做电商网站的公司简介,网站空间商 权限,网络公司起名大全一、安装 1.查看chrome的版本 在浏览器里面输入 chrome://version/ 回车查看浏览器版本 Chrome的版本要和ChromeDriver的版本对应#xff0c;否则会出现版本问题。
2.ChromeDriver的版本选择 114之前的版本#xff1a;https://chromedriver.storage.googleapis.com/index.ht…一、安装 1.查看chrome的版本 在浏览器里面输入 chrome://version/ 回车查看浏览器版本 Chrome的版本要和ChromeDriver的版本对应否则会出现版本问题。
2.ChromeDriver的版本选择 114之前的版本https://chromedriver.storage.googleapis.com/index.html 要选择对应系统的下载 125版本以后下载地址Chrome for Testing availability
只有后面status是绿色对勾的才可以下载驱动大版本一致就可以使用不需版本号一模一样下载所需版本只需点击对应的版本名称即可跳转到对应版本的下载位置。 二、使用 安装依赖pip3 install selenium
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Servicedef html_parser_detail(url,film_id):driver_path /Users/chromedriverservice Service(executable_pathdriver_path)driver webdriver.Chrome(serviceservice)driver.get(url)html_content driver.page_source# 使用BeautifulSoup解析HTMLsoup BeautifulSoup(html_content, html.parser)downhelp_divs soup.find_all(div, class_w960 neworder)# ....解析文档driver.quit() # 需要写在finally中
注意可能出现Mac电脑打不开chromedriver驱动无法验证开发者问题。 需要在驱动文件所在目录下执行xattr -d com.apple.quarantine chromedriver