控制已打开的浏览器

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. 菜鸟学python之程序初体验

    作业来源:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE1/homework/2684 1.字符串操作: 解析身份证号:生日.性别.出生地等. def id ...

  2. 证明与计算(3): 二分决策图(Binary Decision Diagram, BDD)

    0x01 布尔代数(Boolean algebra) 大名鼎鼎鼎的stephen wolfram在2015年的时候写了一篇介绍George Boole的文章:George Boole: A 200-Y ...

  3. PHP7.0-PHP7.3新特性与变更

    到目前为止,PHP7发布已经升级到7.3,本文来总结一下每个版本的变更与新特性 PHP7.0 1. 组合比较符 (<=>) 组合比较符号用于比较两个表达式.当$a小于.等于或大于$b时它分 ...

  4. pstree:command not found

    centos7默认并没有安装pstree,所以会有pstree:command not found yum -y install psmisc

  5. XPath、CSS 选择器 -学习地址

    http://www.w3school.com.cn/cssref/css_selectors.asp http://www.w3school.com.cn/xpath/xpath_syntax.as ...

  6. codeforces476D

    Dreamoon and Sets CodeForces - 476D Dreamoon likes to play with sets, integers and .  is defined as ...

  7. SPFA求最短路——Bellman-Ford算法的优化

    SPFA 算法是 Bellman-Ford算法 的队列优化算法的别称,通常用于求含负权边的单源最短路径,以及判负权环.SPFA 最坏情况下复杂度和朴素 Bellman-Ford 相同,为 O(VE), ...

  8. vim主题颜色

    1.VIM主题 查看Vim示例当前的颜色主题 打开一个Vim窗口,输入命令:color或:colorscheme后回车查看当前的颜色主题. Vim实例中设置颜色主题 输入命令"colorsc ...

  9. MySql自动备份shell

    MySql黑屏备份是每个运维工程师必备的技能,以下是MySQL自动备份脚本: #/bin/bash#This is mysql backup shell on 2019/4/28 BAKUP_DIR= ...

  10. 自动化测试框架【windows版】:JMeter + Ant + Jenkins

    前提条件:windows安装了jmeter.ant.jenkins 安装方法参考汇总目录中对应的博文 截图看不清的,可以调大浏览器倍数看 jenkins驱动ant执行,ant驱动jmeter执行 an ...