zoukankan      html  css  js  c++  java
  • 爬虫—天眼查接口函数

    from selenium import webdriver
    import time
    import re
    from bs4 import BeautifulSoup
    import urllib

    #获取企业基本信息数据
    def get_enterprise_data(ename):
    #搜索页面链接地址
    keyword = urllib.parse.quote(ename)
    url = 'http://www.tianyancha.com/search/'+keyword
    #获得搜索结果页面
    driver = webdriver.PhantomJS(executable_path='/root/phantomjs-2.1.1-linux-x86_64/bin/phantomjs')
    driver.maximize_window()
    driver.get(url)
    time.sleep(2)
    #从搜索结果中点击第一个结果
    driver.find_element_by_class_name('query_name').click()
    time.sleep(2)
    #抓取第一个结果的网页,匹配出需要的字段
    soup = BeautifulSoup(driver.page_source,"html.parser")
    basic_info_list = soup.find_all('p',class_="ng-binding ng-scope")
    data = []
    qiyemingcheng = driver.title.split('】')[1].split('信息查询')[0]
    data.append(qiyemingcheng)
    for i in basic_info_list:
    data.append(i.get_text().strip())

    return data

    print(get_enterprise_data('科润智能'))

  • 相关阅读:
    5、面试题-测试用例篇
    4、面试题-技术篇
    3、面试题-测试流程
    2、面试题-接口测试用例
    全屏圆角弹出框
    Jquery的each退出循环
    拖动DIV
    head里面的其他标记
    更新字段
    Python---序列化
  • 原文地址:https://www.cnblogs.com/wyj690/p/5386978.html
Copyright © 2011-2022 走看看