Coder Social home page Coder Social logo

blue03 / tianyancha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yushengauggie/tianyancha

0.0 1.0 0.0 8.93 MB

天眼查爬虫API,指定的单个/多个企业工商信息一键保存为Excel/JSON格式。A Battery-included Scraper API of Tianyancha, the best Chinese Business Database.

Home Page: https://qzcool.github.io/Tianyancha/

License: GNU General Public License v3.0

Jupyter Notebook 19.70% Python 80.30%

tianyancha's Introduction

Tianyancha 天眼查

输入目标企业的模糊名称/简称,一行代码将目标企业的制定工商信息分类保存为Excel/JSON文件。

  • 模拟登录:基于Selenium的Xpath来定位登录框并传入个人账户信息,一次登录大概6-9秒。
  • 关键字的模糊识别:利用天眼查搜索框的已有模糊检索能力,方便用户仅能提供部分关键字的情况。
  • 元素定位:特殊表格(比如'baseInfo')使用了Selenium提供的API,具体请参考Locating Elements。一般表格使用pandas的read_html方法。

使用方法 Instruction

输入更换为自己的天眼查账户、密码和查询关键字。 生成的结果文件请参考北京鸿智慧通实业有限公司.xlsx中信证券股份有限公司.json

运行下面的示例代码将分别执行:

  1. 单个:“用户User输入密码Password登录后,爬取关键字为Keyword的企业的工商信息(baseInfo),结果返回table_dict并保存为JSON文件。”
  2. 批量:“用户User输入密码Password登录后,程序根据input.xlsx中分别设置的表名来批量爬取多个公司信息,结果返回在由多个table_dict拼接而成的tuple_dicts并分别保存为EXCEL文件。最后,在终端打印出第一个公司的所需信息。”
from tianyancha import Tianyancha
# 单个
table_dict = Tianyancha(username='User', password='Password').tianyancha_scraper(keyword='Keyword', table='baseInfo', export='json')
# 批量
tuple_dicts = Tianyancha(username='User', password='Password').tianyancha_scraper_batch(input_template='input.xlsx', export='xlsx')
tuple_dicts[0]

函数参数 Function Parameters

Tianyancha.tianyancha_scraper(keyword, table='all', use_default_exception=True, change_page_interval=2, export='xlsx'):

参数 类型 说明 范例
keyword string 公司名称,支持模糊或部分检索。 "北京鸿智慧通实业有限公司"
table list or string, default 'all' 需要爬取的表格信息。和官方的元素名称一致,具体请参考表格名称中英文对照表。 ['baseInfo', 'staff', 'invest']
use_default_exception boolean, default True 是否使用默认的排除列表。以忽略低价值表格为代价来加快爬取速度。 False
change_page_interval float, default 2 爬取多页的时间间隔(秒)。避免频率过快IP地址被官方封禁。 1.5
export string, default 'xlsx' 输出保存格式,'xlsx'/'json'。 'json'

表格参数对照表 Table Parameters Mapping Chart

参数结尾有"*"的为可能有误的参数名称,请手工复查div._container_后面的内容。

名称 参数 说明
上市信息 Listed information 股票行情 volatilityNum
企业简介 stockNum
高管信息 seniorPeople
参股控股 holdingCompany
上市公告 announcement
十大股东 topTenNum
十大流通 tenTradableNum
发行相关 issuanceRelatedNum
股本结构 shareStructure
股本变动 equityChange
分红情况 bonus
配股情况 allotment
公司背景 Company background 工商信息 baseInfo 企业基础工商信息,包含统一社会信用代码/注册资本/注册日期/法定代表人/经营范围等信息。
天眼风险 riskInfo
股权穿透图 graphTreeInfo
主要人员 staff
股东信息 holder
对外投资 invest
最终受益人 humanholding
实际控制权 companyholding
财务简析 financialAnalysis* 付费可见内容。
企业关系 graph
变更记录 changeinfo
历史沿革 graphTimeInfo
公司年报 report*
分支机构 branch
司法风险 Judicial risk 开庭公告 announcementCount
法律诉讼 lawsuit
法院公告 court
失信人信息 dishonest
被执行人 zhixing
司法协助
经营风险 Operational risks 经营异常 abnormal
行政处罚 punish, punishmentCreditchina
严重违法
股权出质 equity
动产抵押
欠税公告
司法拍卖 judicialSale
清算信息
知识产权出质
公示催告 publicnoticeItem
公司发展 Company development 融资历史 rongzi
核心团队 teamMember
企业业务 firmProduct
投资事件 touzi
竞品信息 jingpin
经营状况 Operation status 招聘信息 recruit
行政许可 licensing licensingXyzg
税务评级 taxcredit
抽查检查 check
资质证书 certificate
招投标信息 bid
产品信息 product
微信公众号 wechat
进出口信用 importAndExport
债券信息 bond
购地信息 purchaselandV2
电信许可 permission
知识产权 Intellectual property 商标信息 tminfo
专利信息 patent
软件著作权 copyright
作品著作权 copyrightWorks
网站备案 icp
历史信息 Past
工商信息 pastICCount
股东信息 pastHolderCount
对外投资 pastInvestCount
开庭公告 pastAnnouncementCount
法律诉讼 passtLawsuitCount
法院公告 pastCourtCount
失信人信息 pastDishonest
被执行人 pastZhixing
行政处罚 pastPunishmentIC, pastPunishmentCreditCN
股权出质 pastEquitycount
动产抵押
行政许可 getPastLicenseCN

默认排除列表 Default Exception List

use_default_exception参数的解释。

list_exception = ['recruit', 'tmInfo', 'holdingCompany', 'invest', 'bonus', 'firmProduct', 'jingpin', \
                'bid', 'taxcredit', 'certificate', 'patent', 'copyright', 'product', 'importAndExport', \
                'copyrightWorks', 'wechat', 'icp', 'announcementcourt', 'lawsuit', 'court', \
                'branch', 'touzi', 'judicialSale', 'bond', 'teamMember', 'check']

运行依赖 Dependencies

  1. Chrome浏览器
  2. Chrome-webdriver:将chromedriver.exe(Windows)或chromedriver.dmg(Mac)移动到本地Python安装目录下。
    1. 百度网盘下载
    2. 官方下载(需要代理访问)
  3. Requirements.txt

捐助 Donation

捐助是一种美德。 ❤️💛💙

  1. 资金

  1. 点赞

请为知乎相关问题像天眼查这种网站怎么进行全爬虫?回答点赞,帮助更多人受惠于本项目。

tianyancha's People

Contributors

qzcool avatar tfj001 avatar yushengauggie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.