盖得化工_采集某省份所有公司的链接网址

 

 

Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门

https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6EmUbbW&id=564564604865

 

 

 

 

# -*- 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


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()

for page in list_pages_hubei:
    browser.get(page)
    links_list=Get_corporation_site()
    list_corporation_link.append(links_list)
    
#测试速度太慢,主要是反复调用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/']]

'''

  

 

速度太慢,尝试翻页速度

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值