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翻页测试的更多相关文章

  1. (java)selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出

    selenium webdriver学习---实现简单的翻页,将页面内容的标题和标题链接取出: 该情况适合能能循环page=1~n,并且每个网页随着循环可以打开的情况, 注意一定是自己拼接的url可以 ...

  2. 万能js实现翻页,动态生成内容自动翻页,兼容各种浏览器(已测试)----神器版!

    转--http://www.2cto.com/kf/201402/277535.html 万能js实现翻页,动态生成内容自动翻页,兼容各种浏览器(已测试)----神器版! 2014-02-11     ...

  3. Web测试——翻页功能测试用例

    参考:https://wenku.baidu.com/view/e6462707de80d4d8d15a4f1e.html?rec_flag=default&mark_pay_doc=2&am ...

  4. python 使用selenium模块爬取同一个url下不同页的内容(浏览器模拟人工翻页)

    页面翻页,下一页可能是一个新的url 也有可能是用js进行页面跳转,url不变,解决方法是实现浏览器模拟人工翻页 目标:爬取同一个url下不同页的数据(上述第二种情况) url:http://www. ...

  5. selenium 之百度搜索,结果列表翻页查询

    selenium之百度搜索,结果列表翻页查询 by:授客 QQ:1033553122 实例:百度搜索,结果列表翻页查询 解决问题:解决selenium driver获取web页面元素时,元素过期问题 ...

  6. 用fiddler测试移动端翻页

    大家在移动端是怎么测试翻页的,肯定都是下拉或上滑吧,我也是这样测试的 但如果你要验证数据是否与pc端数据一致时,可能是第一页,第二页看看,或最后几页数据看看,在pc端看简单,直接点击最后一页就行,在移 ...

  7. C# 自动翻页 PPT 测试脚本

    本文告诉大家一个可以使用的 C# 脚本,可以用来自动打开 PPT 文件,然后不断执行翻页.每次翻页都截图.翻页之后自动关闭 PPT 再次打开 最近发现给 Office 做的插件,会在一定翻页次数的时候 ...

  8. selenium模块跳过用户名密码验证码输入,加载浏览器标签和cookie,进行翻页爬虫多页动态加载的数据(js)

    能解决登陆一次后,之后不需要二次登陆的动态加载数据,网页保存的cookie和标签,加入到selenium自动化测试浏览器中 1 from selenium import webdriver 2 imp ...

  9. 盖得化工----requests/bs4---采集二级网址

    Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...

随机推荐

  1. Linux内核分析第四章 读书笔记

    Linux内核分析第四章 读书笔记 第一部分--进程调度 进程调度:操作系统规定下的进程选取模式 面临问题:多任务选择问题 多任务操作系统就是能同时并发地交互执行多个进程的操作系统,在单处理器机器上这 ...

  2. Python学习笔记 -- 第五章

    模块 使用模块可以提高了代码的可维护性.其次,编写代码不必从零开始.当一个模块编写完毕,就可以被其他地方引用.我们在编写程序的时候,也经常引用其他模块,包括Python内置的模块和来自第三方的模块: ...

  3. C语言复制文件的两种简单的方法【从根本解决问题】

    网上的方法大致有这样几种: 1.使用操作系统提供的复制文件的API 2.使用C语言本身提供的复制文件的函数 3.直接读写文件,从文件角度来操作,从而直接将一个文件复制 这里我们使用的就是这第三种. 复 ...

  4. jq源码解析之绑在$,jQuery上面的方法

    1.当我们用$符号直接调用的方法.在jQuery内部是如何封装的呢?有没有好奇心? // jQuery.extend 的方法 是绑定在 $ 上面的. jQuery.extend( { //expand ...

  5. FICO模块

  6. FICO基础知识(四)

    What is the organizational structure for CO? Operating Concern 经营组织 Controlling Area 成本控制范围 Profit c ...

  7. 操作系统+编程语言的分类+执行python程序的两种方式+变量

    1.什么是操作系统? 操作系统就是一个协调\管理\控制计算机硬件资源与软件资源的一个控制程序. 2.为何要操作系统? a.把复杂的硬件操作封装成简单的功能\接口用来给用户或者程序来使用(文件) b.把 ...

  8. 软件工程_10th weeks

    不管是什么原因,都没有在周三24:00前发布博客,赶紧用行动补上~ psp DATE START_TIME END_TIME EVENT TYPE     DELTA 5.8 9:00 12:00 论 ...

  9. 使用ssh tunnel 来做代理或跳板

    接前文 http://www.cnblogs.com/piperck/p/6188984.html  使用ssh config配置文件来管理ssh连接 前文说了如何配置自己的ssh config 来方 ...

  10. 监控系统 & monitoring & DevOps

    监控系统 & monitoring & DevOps https://github.com/topics/monitoring https://github.com/marketpla ...