zoukankan      html  css  js  c++  java
  • 盖得化工_采集某省份所有公司的链接网址

    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/']]
    
    '''
    

      

    速度太慢,尝试翻页速度

  • 相关阅读:
    vs2010下载
    .Net执行cmd命令
    本Blog链接交换
    DNN 04.09.01 StartKit中的新内容。
    如何使一个你没有源代码的DLL文件变为强命名的(Strong Name)
    "Error Creating Control" when creating a custom control
    GridView导出为Excel后,导出的.xls文件无法作为源文件导入的问题
    DotNetNuke的C#版本
    DotNetNuke 5.0 放到CodePlex上提供下载了
    在VS中使用独立的项目(Project)开发DNN模块
  • 原文地址:https://www.cnblogs.com/webRobot/p/5473309.html
Copyright © 2011-2022 走看看