控制已打开的浏览器

https://www.cnblogs.com/lovealways/p/9813059.html

selenium、自动填充文本框、自动点按钮

https://blog.csdn.net/github_26672553/article/details/78579038

selenium driver  驱动器下载:

http://npm.taobao.org/mirrors/chromedriver/

获取标签属性值

https://www.linuxhub.org/?p=3801

from openpyxl import load_workbook
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from openpyxl.utils import get_column_letter
import time chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_driver = "D:\Program Files\Python36\Scripts\chromedriver.exe"
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options) driver.get('http://search.anccnet.com/searchResult2.aspx')
wb = load_workbook(r'C:\Users\admin\Desktop\T1.xlsx')
sheet = wb.get_sheet_by_name('Sheet1') for cell in list(sheet.columns)[0]:
try:
searchInput = driver.find_element_by_id('keyword')
searchInput.clear()
# searchInput.send_keys('6954767470573')
# searchInput.send_keys('6923146102015')
searchInput.send_keys(cell.value) button = driver.find_element_by_id('gdsBtn')
button.click() tiaomaID4 = driver.find_element_by_class_name('p-info').find_elements_by_tag_name("a")[0].text
changshang5 = driver.find_element_by_id('repList_ctl00_firmLink').text
zhuangtai6 = driver.find_element_by_id('repList_ctl00_status').text[0:2]
time.sleep(3)
ret = driver.find_element_by_class_name('p-info').find_elements_by_tag_name("a")[0].get_attribute("href")
driver.get(ret) name7 = driver.find_element_by_id('Att_Sys_zh-cn_141_G').text
ename8 = driver.find_element_by_id('Att_Sys_en-us_141_G').text
fenlei9 = driver.find_element_by_id('Att_Sys_zh-cn_22_G').text
pinpai10 = driver.find_element_by_id('Att_Sys_zh-cn_304_G').text
guige11 = driver.find_element_by_id('Att_Sys_zh-cn_332_G').text
kuandu12 = driver.find_element_by_id('Att_Sys_zh-cn_101_G').text
gaodu13 = driver.find_element_by_id('Att_Sys_zh-cn_106_G').text
shendu14 = driver.find_element_by_id('Att_Sys_zh-cn_118_G').text
yuanchanguo15 = driver.find_element_by_id('Att_Sys_zh-cn_74_G').text
chandi16 = driver.find_element_by_id('Att_Sys_zh-cn_405_G').text
zhuangpeiguo17 = driver.find_element_by_id('Att_Sys_zh-cn_171_G').text
jibendanwei18 = driver.find_element_by_id('Att_Sys_zh-cn_107_G').text
lingshoudanwei19 = driver.find_element_by_id('Att_Sys_zh-cn_204_G').text
guanjianzi20 = driver.find_element_by_id('Att_Sys_zh-cn_11_G').text
lingshoujia21 = driver.find_element_by_id('Att_Sys_zh-cn_196_G').text try:
img = driver.find_element_by_id('imageListDiv')
except Exception as e:
img = '' sheet[get_column_letter(4) + str(cell.row)] = tiaomaID4
sheet[get_column_letter(5) + str(cell.row)] = changshang5
sheet[get_column_letter(6) + str(cell.row)] = zhuangtai6
sheet[get_column_letter(7) + str(cell.row)] = name7
sheet[get_column_letter(8) + str(cell.row)] = ename8
sheet[get_column_letter(9) + str(cell.row)] = fenlei9
sheet[get_column_letter(10) + str(cell.row)] = pinpai10
sheet[get_column_letter(11) + str(cell.row)] = guige11
sheet[get_column_letter(12) + str(cell.row)] = kuandu12
sheet[get_column_letter(13) + str(cell.row)] = gaodu13
sheet[get_column_letter(14) + str(cell.row)] = shendu14
sheet[get_column_letter(15) + str(cell.row)] = yuanchanguo15
sheet[get_column_letter(16) + str(cell.row)] = chandi16
sheet[get_column_letter(17) + str(cell.row)] = zhuangpeiguo17
sheet[get_column_letter(18) + str(cell.row)] = jibendanwei18
sheet[get_column_letter(19) + str(cell.row)] = lingshoudanwei19
sheet[get_column_letter(20) + str(cell.row)] = guanjianzi20
sheet[get_column_letter(21) + str(cell.row)] = lingshoujia21 if img:
sheet[get_column_letter(21) + str(cell.row)] = ret wb.save(r'C:\Users\admin\Desktop\T1.xlsx')
# print('end') time.sleep(3)
driver.back() except Exception as e:
print('%s 错误'%cell.value)
time.sleep(3)
driver.back() wb.close()

python selenium 模块的更多相关文章

  1. python selenium模块调用浏览器的时候出错

    python selenium模块使用出错,这个怎么改 因为不同版本更新不同步问题,浏览器都要另外下一个驱动.

  2. python selenium模块 css定位

    selenium是python的非标准库,使用时需要下载安装 安装命令  pip install selenium selenium是python的自动化测试模块,可以模拟浏览器的行为 所以在使用之前 ...

  3. python + selenium 模块封装及参数化

    模块封装 示例代码: baidu.py from time import sleep from selenium import webdriver driver = webdriver.Chrome( ...

  4. python selenium 模块的安装及使用

    安装 pip install selenium 或者到https://pypi.python.org/pypi/selenium 下载setup安装包,之后进入目录后运行python setup.py ...

  5. python - selenium模块简介

    为什么要使用Selenium? 很多浏览器渲染页面的方式都很难找出其规律, 但是利用Selenium来驱动加载网页就可以直接拿到javaScript渲染后的结果了, 不需要再担心其相关的加密系统 声明 ...

  6. Python—selenium模块(浏览器自动化工具)

    selenium可以用来完成浏览器自动化相关的操作,写一些代码制定一些基于浏览器自动化的相关操作(行为动作),当代码执行后,浏览器就会自动触发相关的事件 安装方法: pip install selen ...

  7. python selenium模块 xpath定位

    ''' 附w3xpath语法地址 https://www.w3school.com.cn/xpath/xpath_syntax.asp 总结: 返回匹配到所有符合条件的第一个节点,对象是 <cl ...

  8. Python爬虫——selenium模块

    selenium模块介绍 selenium最初是一个测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全模拟浏览 ...

  9. python 全栈开发,Day136(爬虫系列之第3章-Selenium模块)

    一.Selenium 简介 selenium最初是一个自动化测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全 ...

随机推荐

  1. PHP为前端CSS和JS增加时间戳版本号

    一.PHP代码如下: function addVersion($url){ $version = date("Y-m-d H:i:s",filemtime($_SERVER['DO ...

  2. .netcore 读取ansi编码

    public class FileHelper { //根据文件自动觉察编码并输出内容 public static string GetText(string path) { StringBuilde ...

  3. Linux安装Kafka

    https://blog.csdn.net/qq_33257527/article/details/85227478 https://jingyan.baidu.com/article/36d6ed1 ...

  4. PHP开发高可用高安全App后端

    基于thinkphp5开发的APP,涵盖阿里大于,七牛云图片上传,RestfulApi,短信验证, 需要联系我:QQ:1844912514

  5. servlet(2)servlet过滤器

    1.servlet过滤器 用于动态的拦截servlet请求或响应,以变更或使用其中的信息. (1)过滤器和servlet是多对多的关系,即一个过滤器可以用于一个或多个servlet,多个过滤器也可以用 ...

  6. 曝Wi-Fi重大缺陷:你浏览的或是个假网站

    今年央视315晚会上曝光的Wi-Fi探针收集用户信息的热度还未消退,阿里安全专家研究发现了Wi-Fi的重大新问题:基于WPA/WPA2设计上存在的一些缺陷,用户在使用公共Wi-Fi时,被攻击者钓鱼,进 ...

  7. leanote 信息栏显示笔记本和笔记类型

    本文解决如下两个问题: 1. 在列表视图下使用搜索时,不知道搜出来的笔记属于哪个笔记本.(摘要视图下是有显示的) 2. 增加显示笔记类型(markdown 或 富文本) 修改resources\app ...

  8. 洛谷P5119 Convent 题解

    题目 很好想的一道二分题,首先,二分一定满足单调性,而题目中非常明显的就是用的车越多,所用时间越少,所以可以枚举时间,判断是否可以比\(m\)少. 然后在二分时,更是要注意下标的一些问题,也要注意车和 ...

  9. [pip]upgrade outdated pip package on windows / 在windows上更新所有过时的pip包

    首先更新pip自身: python -m pip install -U pip 查询过期包: pip list --outdated --format=columns Package Version ...

  10. EnableEurekaServer基本配置

    pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...