Python爬虫Selenium安装

news/2024/7/19 11:05:31 标签: selenium, 爬虫, python

selenium">安装Selenium

pip install selenium

Chromedriver

https://sites.google.com/a/chromium.org/chromedriver/downloads
进入页面,找到最后发布版本
这里写图片描述
转到:
https://chromedriver.storage.googleapis.com/index.html?path=2.33/
这里写图片描述
找到适合自己的系统版本

下载解压到 python 环境的Scripts文件夹里面
在命令行中输入 chromedriver 打印出提示信息表示安装完成

Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 9515
Only local connections are allowed.

如果出现以下情况:

要么更新chrome,要么重新降低chromedriver的版本

>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 151, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 240, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "D:\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception: Chrome version must be >= 60.0.3112.0    # 版本必须大于60.x
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.14393 x86_64)

http://www.niftyadmin.cn/n/1736802.html

相关文章

几个小例子引发的思考

楚广明老师的c#教程每一节都会给出几个小例子让大家联系&#xff0c;对于初学者来说这确实是一件很纠结的事情&#xff0c;下面我把这几个小例子简单的写一下。同时看一下我们学到了什么 1、面向过程版的圆周长面积计算 <span style"font-size:18px;">using Sy…

Python爬虫Selenium使用

官方文档&#xff1a; http://selenium-python.readthedocs.io/installation.html#introduction 声明浏览器对象 Seleninum支持很多浏览器&#xff0c;但是如果系统中浏览器不存在就会报错 from selenium import webdriver # 引入webdriver包 browser webdriver.Chrome() …

白话面向对象

关于面向对象的学习&#xff0c;将是一个长期的过程&#xff0c;每一个阶段都会有不同的看法&#xff0c;现在对面向对象中的各种术语有有了一点新的认识&#xff0c;我以白话的形式描述出来。 1.类和对象 一个对象就是一个实体&#xff0c;你是一个对象&#xff0c;我是一个对…

requests+正则表达式爬猫眼电影TOP100

爬取地址&#xff1a;http://maoyan.com/board/ 提示&#xff1a;很抱歉&#xff0c;您的访问被禁止 需要伪装浏览器&#xff0c;在headers中添加’User-Agent’字典内容 headers {User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like…

Python爬取今日头条搜索的照片。使用requests+正则表达式

爬取网页&#xff1a;http://www.toutiao.com/search/?keyword%E8%A1%97%E6%8B%8D 1&#xff0c;分析爬取页面&#xff0c;找到页面信息 在Chrome按F12打开开发者工具&#xff0c;查找网页内容的请求位置 找了doc中发现内容都是加载&#xff0c;查看JS内容页面内容无关。 …

设计模式大总结-创建型模式

上一篇简单的介绍了下设计模式的定义、原则和分类&#xff0c;现在我将分别介绍一下这几23个设计模式。 今天我要说的是创建型模式&#xff0c;它包括简单工厂模式、抽象工厂模式、工厂方法模式、单例模式、建造者模式和原型模式。 1、简单工厂模式 主要用于创建对象。添加新…

Python爬取淘宝搜索页,使用Selenium+BeautifulSoup

使用Selenium驱动chrome页面&#xff0c;获得淘宝信息并用BeautifulSoup分析得到结果 使用Selenium时注意页面的加载判断&#xff0c;以及加载超时的异常处理 import json import re from bs4 import BeautifulSoup from selenium import webdriver from selenium.common.exc…

设计模式大总结2-结构型模式

上篇我们介绍完了创建型模式&#xff0c;今天我们继续总结结构型模式&#xff0c;它分别包括适配器模式、装饰模式、桥接模式、组合模式、享元模式、代理模式和外观模式。 1、适配器模式 定义&#xff1a;将一个类的接口转换成客户希望的另外一个接口。--------------双方都不…