iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >python 3 的selenium模块
  • 611
分享到

python 3 的selenium模块

模块pythonselenium 2023-01-31 07:01:35 611人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

基于python 3 的selenium模块实现网页自动登陆 ----Http://blog.csdn.net/u010637662/article/details/53612197[python爬虫] Selenium实现自动登录163邮

基于python 3 的selenium模块实现网页自动登陆

----Http://blog.csdn.net/u010637662/article/details/53612197


[python爬虫] Selenium实现自动登录163邮箱和Locating Elements介绍
----http://blog.csdn.net/eastmount/article/details/47825633


selenium之 chromedriver与chrome版本映射表(更新至v2.30)
----http://blog.csdn.net/huilan_same/article/details/51896672


[Python爬虫] Selenium自动访问Firefox和Chrome并实现搜索截图

----http://blog.csdn.net/eastmount/article/details/47799865


python-selenium-firefox环境搭建时常遇到的小问题

----http://www.cnblogs.com/Jindy-mine/p/6430000.html



firefox 报错“os.path.basename(self.path), self.start_error_message)

selenium.common.exceptions.WEBDriverException: Message: 'geckodriver' executable needs to be in PATH”的解决办法:


1. selenium 3.x开始,webdriver/firefox/webdriver.py的__init__中,executable_path="geckodriver";而2.x是executable_path="wires"
2. firefox 47以上版本,需要下载第三方driver,即geckodriver;在http://docs.seleniumhq.org/download/的Third Party Drivers, Bindings, and Plugins下面找到Mozilla GeckoDriver,下载到任意电脑任意目录,解压后将该路径加入到PC的path(针对windows)即可。




示例:

#!/usr/bin/python
# -*- coding: utf-8 -*-


import time
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
  
chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver
  
driver = webdriver.Chrome(chromedriver)
driver.get("http://172.16.77.160:8080/")
assert "XORMEDIA" in driver.title  
user = driver.find_element_by_name("user_id")
user.send_keys("su")
elem_pwd = driver.find_element_by_name("passWord")
elem_pwd.send_keys("su")
elem_pwd.send_keys(Keys.RETURN)
try:
    if driver.find_element_by_id('_PM'):
        driver.find_element_by_id('_PM').click()
except:
    print('can not find PM')
try:
    if driver.find_element_by_xpath('//*[@id="_label"]/tbody/tr[3]/td/a/img'):
        driver.find_element_by_xpath('//*[@id="_label"]/tbody/tr[3]/td/a/img').click()
except:
    print('can not enter PM')

driver.switch_to_frame('left')
driver.switch_to_frame('leftMainFrame')
try:
    if driver.find_element_by_xpath('/html/body/form/table[1]/tbody/tr[3]/td/a'):
        driver.find_element_by_xpath('/html/body/form/table[1]/tbody/tr[3]/td/a').click()
except:
    print('can not open 电子节目单列表')
print(driver.find_element_by_xpath('/html/body/form/table[1]/tbody/tr[3]/td/a').text)
driver.switch_to_default_content()
driver.switch_to_frame('frameb')
driver.switch_to_frame('mainFrame_b')
try:
    if driver.find_element_by_xpath('//*[@id="objsearchCondition"]/tbody/tr[1]/td[2]/select/option[18]'):
        driver.find_element_by_xpath('//*[@id="objSearchCondition"]/tbody/tr[1]/td[2]/select/option[18]').click()
except:
    print('can not open CCTV1')
driver.find_element_by_xpath('//*[@id="objSearchCondition"]/tbody/tr[1]/td[4]/a').click()    
       
assert "test" in driver.title   
driver.close()  
driver.quit()


--结束END--

本文标题: python 3 的selenium模块

本文链接: https://www.lsjlt.com/news/191688.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • python 3 的selenium模块
    基于python 3 的selenium模块实现网页自动登陆 ----http://blog.csdn.net/u010637662/article/details/53612197[Python爬虫] Selenium实现自动登录163邮...
    99+
    2023-01-31
    模块 python selenium
  • python爬虫之selenium模块
    目录一、什么是Selenium二、selenium安装1、PhantomJS: 无可视化界面的浏览器(无头浏览器)2、下载浏览器驱动三、selenium基本使用1、声明浏览器对象He...
    99+
    2024-04-02
  • python爬虫selenium模块详解
    目录selenium模块 selenium基本概念基本使用基于浏览器自动化的操作selenium处理iframe:selenium模拟登陆QQ空间无头浏览器和规避检测selenium...
    99+
    2024-04-02
  • 基于python 3 的selenium
    本文主要是运用selenium模块模拟登陆新浪微博 python webdriver环境搭建教程:http://blog.csdn.net/nanjunxiao/article/details/7957326 # -*- c...
    99+
    2023-01-31
    python selenium
  • Python selenium模块的安装和配置教程
    目录一、selenium的安装以及简单应用二、selenium的简单使用三、selenium提取数据1、driver对象常用的属性和方法2、driver对象定位标签元素获取标签对象的...
    99+
    2024-04-02
  • 3 - collections 模块
    collections 数据类型主要是为了弥补 list /tuple / dict 的额外数据类型 ChainMap 代码: import collections ## 赋值,合并字典的作用 a = {'a':"A"} b = {"b...
    99+
    2023-01-31
    模块 collections
  • python爬虫之selenium模块怎么使用
    这篇文章主要介绍了python爬虫之selenium模块怎么使用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇python爬虫之selenium模块怎么使用文章都会有所收获,下面我们一起来看看吧。一、什么是Se...
    99+
    2023-06-30
  • python 3.x 分析日志的模块(正
    #导入正则模块 import re auth="no_shutdown_" ''' 分析日志的模块,查找日志中标志性信息产生的次数 ''' #定义你需要查找的对象的正则表达式wordcheck #需要分析的日志的路径filesource d...
    99+
    2023-01-31
    模块 日志 python
  • 常用模块3
      一.正则表达式   英文全称: Regular Expression. 简称 regex或者re.正则表达式是对字符串操作的一种逻辑公式. 我们一般使用正则表达式对字符串进行匹配和过滤. 使用正则的优缺点:   优点: 灵活, 功能性...
    99+
    2023-01-30
    模块 常用
  • python(3)模块、函数式 、三元运
    一、模块和模块的常用方法__name__判断是否为主文件>>> print __name__   #判断是否是主文件,如果是主文件就返回_main_ __main____file__返回当前.py文件的路径cat /roo...
    99+
    2023-01-31
    函数 模块 python
  • Python导入模块的3种方式小结
    目录导入模块方式一:临时添加模块完整路径导入模块方式二:将模块保存到指定位置导入模块方式三:设置环境变量很多初学者经常遇到这样的问题,即自定义 Python 模板后,在其它文件中用 ...
    99+
    2023-03-10
    Python导入模块
  • 分享3个非常实用的 Python 模块
    目录一、Psutil二、Pendulum三、Pyfiglet一、Psutil Python当中的Psutil模块是个跨平台库,它能够轻松获取系统运行的进程和系统利用率,包括CPU、内...
    99+
    2024-04-02
  • python爬虫之利用selenium模块自动登录CSDN
    目录一、页面分析二、引入selenium模块及驱动2.1 并将安装好的Chromedriver.exe引入到代码中2.2 浏览器驱动引入三、爬虫模拟登录3.1 设置网址链接3.2 切...
    99+
    2024-04-02
  • Python导入模块的3种方式(超级详细)
    很多初学者经常遇到这样的问题,即自定义 Python 模板后,在其它文件中用 import(或 from...import) 语句引入该文件时,Python 解释器同时如下错误: ModuleNotFoundError: No modu...
    99+
    2023-09-12
    python 开发语言 pycharm
  • Python模块:time模块
    time模块:python中处理时间的基础模块,有时间戳,元组,自定义,三种时间表现形式。python中时间戳的值是以1970年1月1日0点开始计算的,单位是秒。时间戳:就是两个时间差的数值。时区:传说中在开发服务器/客户端程序时,时区不一...
    99+
    2023-01-31
    模块 Python time
  • python模块:smtplib模块
    1.使用本地的sendmail协议进行邮件发送格式(1):smtpObj=smtplib.SMTP([host [,port [,local_hostname]]])host:SMTP服务器主机的IP地址或者是域名port:服务的端口号(默...
    99+
    2023-01-31
    模块 python smtplib
  • Python中的sys模块、random模块和math模块
    一、sys运行时环境模块 sys模块负责程序与python解释器的交互,提供了一系列的函数和变量,用于操控python的运行时环境。 用法: sys.argv:命令行参数List,第...
    99+
    2024-04-02
  • 怎么在python中使用selenium模块实现自动登录
    怎么在python中使用selenium模块实现自动登录?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。python可以做什么Python是一种编程语言,内置了许多有效的工具...
    99+
    2023-06-14
  • Python中的time模块和calendar模块
    目录1、时间戳2、时间元组3、获取当前时间4、格式化时间5、格式化日期6、获取CPU时间7、日历模块在Python中对时间和日期的处理方式有很多,其中转换日期是最常见的一个功能。Py...
    99+
    2024-04-02
  • python中的deque模块(collections的deque模块)
    目录 1. deque是python的collections中的一个类 2.deque的简单使用以及它的方法 2.1 创建deque的方法  2.2 创建deque时,并指定大小maxlen,即能装几个元素, 以及d...
    99+
    2023-09-25
    python 开发语言 collections deque 队列
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作