盖得化工--selenium翻页测试
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门
https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6EmUbbW&id=564564604865
以下结果还是费时,尝试reques4,bs4模块

# -*- coding: utf-8 -*-
"""
Created on Mon May 9 09:14:32 2016 @author: Administrator
"""
import requests,bs4,csv,time,selenium,random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys site_hubei="http://china.guidechem.com/suppliers/list_catid-21_area-%E6%B9%96%E5%8C%97"
pages_hubei=31
#所有公司的链接网址_存储列表
list_corporation_link=[] def Get_sites(site,pages):
list_pages=[]
for page in range(1,pages+1):
thePage=site+"-"+"p"+str(page)+".html"
list_pages.append(thePage) return list_pages #采集一页所有公司的二级网址
def Get_corporation_site():
elems=browser.find_elements_by_class_name("dblue")
links_list=[i.get_attribute("href") for i in elems]
return links_list #构造所有湖北页面网址
list_pages_hubei=Get_sites(site_hubei,pages_hubei)
#打开浏览器
browser=webdriver.Firefox()
#获取首页
browser.get(list_pages_hubei[0]) #测试获取前十页公司的二级网址
for i in range(1,10):
links_list=Get_corporation_site()
list_corporation_link.append(links_list)
#翻下一页
page_elem=browser.find_element_by_name("PageNum")
browser.find_element_by_name("PageNum").clear() #清除输入文本框的文字
pageNum=str(i+1)
page_elem.send_keys(pageNum) #输入进入第三页
page_elem.send_keys(Keys.RETURN) #测试速度太慢,主要是反复调用browser.get(page)
'''
[['http://show.guidechem.com/hbsthcsales/',
'http://show.guidechem.com/whdinghuichem/',
'http://show.guidechem.com/hbeixys2001/',
'http://show.guidechem.com/jusheng/',
'http://show.guidechem.com/yongnuopharm/',
'http://show.guidechem.com/gameboy0820/',
'http://show.guidechem.com/whhxk/',
'http://show.guidechem.com/zhuoxinghy/',
'http://show.guidechem.com/nrcaocao/',
'http://show.guidechem.com/hbxyhhgwy/',
'http://show.guidechem.com/jushengkeji/',
'http://show.guidechem.com/jushengchem4/',
'http://show.guidechem.com/eva1210/',
'http://show.guidechem.com/whdhwy/',
'http://show.guidechem.com/chenjinping2014/',
'http://show.guidechem.com/hbjltchem/',
'http://show.guidechem.com/jlt7796/',
'http://show.guidechem.com/saichuang123/',
'http://show.guidechem.com/apidky/',
'http://show.guidechem.com/finetechwh/'],
['http://show.guidechem.com/csw288/',
'http://show.guidechem.com/cuizhiying123/',
'http://show.guidechem.com/sjpxkj/',
...........
ttp://show.guidechem.com/hengshuochem/',
'http://show.guidechem.com/DSHKJYXGS/',
'http://show.guidechem.com/HUBEIBOKAI/',
'http://show.guidechem.com/xiangdetech/']] '''
盖得化工--selenium翻页测试的更多相关文章
- (java)selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出
selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出: 该情况适合能能循环page=1~n,并且每个网页随着循环可以打开的情况, 注意一定是自己拼接的url可以 ...
- 万能js实现翻页,动态生成内容自动翻页,兼容各种浏览器(已测试)----神器版!
转--http://www.2cto.com/kf/201402/277535.html 万能js实现翻页,动态生成内容自动翻页,兼容各种浏览器(已测试)----神器版! 2014-02-11 ...
- Web测试——翻页功能测试用例
参考:https://wenku.baidu.com/view/e6462707de80d4d8d15a4f1e.html?rec_flag=default&mark_pay_doc=2&am ...
- python 使用selenium模块爬取同一个url下不同页的内容(浏览器模拟人工翻页)
页面翻页,下一页可能是一个新的url 也有可能是用js进行页面跳转,url不变,解决方法是实现浏览器模拟人工翻页 目标:爬取同一个url下不同页的数据(上述第二种情况) url:http://www. ...
- selenium 之百度搜索,结果列表翻页查询
selenium之百度搜索,结果列表翻页查询 by:授客 QQ:1033553122 实例:百度搜索,结果列表翻页查询 解决问题:解决selenium driver获取web页面元素时,元素过期问题 ...
- 用fiddler测试移动端翻页
大家在移动端是怎么测试翻页的,肯定都是下拉或上滑吧,我也是这样测试的 但如果你要验证数据是否与pc端数据一致时,可能是第一页,第二页看看,或最后几页数据看看,在pc端看简单,直接点击最后一页就行,在移 ...
- C# 自动翻页 PPT 测试脚本
本文告诉大家一个可以使用的 C# 脚本,可以用来自动打开 PPT 文件,然后不断执行翻页.每次翻页都截图.翻页之后自动关闭 PPT 再次打开 最近发现给 Office 做的插件,会在一定翻页次数的时候 ...
- selenium模块跳过用户名密码验证码输入,加载浏览器标签和cookie,进行翻页爬虫多页动态加载的数据(js)
能解决登陆一次后,之后不需要二次登陆的动态加载数据,网页保存的cookie和标签,加入到selenium自动化测试浏览器中 1 from selenium import webdriver 2 imp ...
- 盖得化工----requests/bs4---采集二级网址
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...
随机推荐
- 2017-2018-2 1723《程序设计与数据结构》第十一周作业 & 实验三 & (总体)第三周结对编程 总结
作业地址 第十一次作业:https://edu.cnblogs.com/campus/besti/CS-IMIS-1723/homework/1933 (作业界面已评分,可随时查看,如果对自己的评分有 ...
- github第一次作业链接
https://github.com/xuhuzi/test/blob/master/test1 https://github.com/xuhuzi/test/blob/master/test2 ht ...
- 使用a标签实现文件的下载与保存
<a>标签的常规使用是定义超链接,用于从一个页面链接到另一个页面,并且需要指定链接目标href,除了定义超链接外,<a>还可以实现文件的保存,直接设置a标签的href属性,但是 ...
- Tomcat7解决java.lang.OutOfMemoryError: PermGen space
上述两参数,可根据实际情况,逐渐调大.
- [转帖]DevOps/TestOps概念
发现收藏不好用..还是转吧.. https://www.cnblogs.com/fnng/p/8232410.html DevOps/TestOps概念 2018-01-07 22:02 by 虫师, ...
- 解决从pip上下载的最新flask版本不能运行flaskr和最新特性的问题
由于在测试flask的单元测试.所以准备弄个环境,查询官方文档发现flask源码里面有一个example文件夹里面有个flaskr应用 可供测试 看了一下readme文档,大致是这样 / Flaskr ...
- .gitignore & .DS_Store
.gitignore & .DS_Store https://stackoverflow.com/questions/107701/how-can-i-remove-ds-store-file ...
- 如何判断一条记录什么字段被修改了 [问题点数:40分,结帖人bluesukeke]
查询出来数据,在数据集编辑状态下,如何判断一条记录被修改了,哪些字段被修改了. 可用adoquery的Delta屬性...eg: ClientDataSet1.Delta... PS:POST前是準確 ...
- LODOP打印控件关联输出各内容
Lodop打印控件利用SET_PRINT_STYLEA里面的“LinkedItem”可以把多个独立的内容关联起来,让它们顺序打印.这样,就可以实现很多效果,例如一些内容紧跟着表格下方输出,关联表格后就 ...
- Visual Studio Code之常备快捷键
官方快捷键大全:https://code.visualstudio.com/docs/customization/keybindings Visual Studio Code是个牛逼的编辑器,启动非常 ...