python selenium 模块
控制已打开的浏览器
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 模块的更多相关文章
- python selenium模块调用浏览器的时候出错
python selenium模块使用出错,这个怎么改 因为不同版本更新不同步问题,浏览器都要另外下一个驱动.
- python selenium模块 css定位
selenium是python的非标准库,使用时需要下载安装 安装命令 pip install selenium selenium是python的自动化测试模块,可以模拟浏览器的行为 所以在使用之前 ...
- python + selenium 模块封装及参数化
模块封装 示例代码: baidu.py from time import sleep from selenium import webdriver driver = webdriver.Chrome( ...
- python selenium 模块的安装及使用
安装 pip install selenium 或者到https://pypi.python.org/pypi/selenium 下载setup安装包,之后进入目录后运行python setup.py ...
- python - selenium模块简介
为什么要使用Selenium? 很多浏览器渲染页面的方式都很难找出其规律, 但是利用Selenium来驱动加载网页就可以直接拿到javaScript渲染后的结果了, 不需要再担心其相关的加密系统 声明 ...
- Python—selenium模块(浏览器自动化工具)
selenium可以用来完成浏览器自动化相关的操作,写一些代码制定一些基于浏览器自动化的相关操作(行为动作),当代码执行后,浏览器就会自动触发相关的事件 安装方法: pip install selen ...
- python selenium模块 xpath定位
''' 附w3xpath语法地址 https://www.w3school.com.cn/xpath/xpath_syntax.asp 总结: 返回匹配到所有符合条件的第一个节点,对象是 <cl ...
- Python爬虫——selenium模块
selenium模块介绍 selenium最初是一个测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全模拟浏览 ...
- python 全栈开发,Day136(爬虫系列之第3章-Selenium模块)
一.Selenium 简介 selenium最初是一个自动化测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全 ...
随机推荐
- CentOS7.x安装kickstart
kickstart简介 kickstartkickstart是RedHat公司开源的软件,所以对CentOS兼容性最好,是一种无人值守的安装方式就是将手动安装配置的步骤,记录到文件中,然后通过kick ...
- form单选框
form中的单选框: var resultStartRadio = new Ext.form.RadioGroup({ id : 'resultStartRadio', name :"for ...
- visual studio中各文件的输出路径
dll或exe输出路径一般在 配置属性->链接器->常规->输出文件 中 若该路径与 配置属性->常规 中的输出目录+目标文件名+目标文件扩展名不一致,可能会有提示,建议保持一 ...
- ansible 模块 分享
A a10_server 管理A10 Networks AX / SoftAX / Thunder / vThunder设备 a10_service_group 管理A10网络设备的服务组 a10_v ...
- Asp.Net Core Options模式的知识总结
Options模式是Asp.Net Core中用于配置的一种模式,它利用了系统的依赖注入,并且还可以利用配置系统.它使我们可以采用依赖注入的方法直接使用绑定的一个POCO对象,这个POCO对象就叫做O ...
- LVS结合keepalive
LVS可以实现负载均衡,但是不能够进行健康检查,比如一个rs出现故障,LVS 仍然会把请求转发给故障的rs服务器,这样就会导致请求的无效性.keepalive 软件可以进行健康检查,而且能同时实现 L ...
- Url校验正则
最近需要对HTTP请求合法性做一些校验,在网上查找了一些关于URL合法性的正则表达式. 在github上的有个关于weburl匹配的gist: https://gist.github.com/dper ...
- django模板引擎自定义变量
定义临时变量: {% with i=1 %} {{i}} {% endwith %} 定义对临时变量操作的tag 在templatetags中创建set_val.py 内容是 from django ...
- rabbtimq非持久化测试
send端代码 import pika,time,threading class send(): def __init__(self,que_nam='hello'): self.credential ...
- elastic的gc相关
https://www.jianshu.com/p/1f450826f62e gc原理介绍 相关优化 https://zhaoyanblog.com/archives/319.html 问题 ht ...