Coder Social home page Coder Social logo

phantomjs-tianyancha's Introduction

tianyancha

天眼查数据抓取

利用 phantomjs抓取动态js渲染的网页

##origindata目录存储 原始xlsx数据

##tempdata目录存储 临时的中间数据,用来进行数据的转换

##storage目录存储 获取超链接/详细信息时程序中断的位置,以便下一次程序启动后接着上一次中断位置开始搜索

##result目录存储 最终生成的xlsx数据

首先安装依赖文件 进入命令行工具 进入文件根目录 运行命令 cnpm install 等待安装完依赖文件之后执行以下命令

1、进入命令行工具 运行命令 node step1_init.js 置空相关txt文件,以及storage目录中的缓存文件

2、运行命令 node step2_changeOriginData.js 将xlsx内容转换成txt格式--(因为phantomjs不支持读写xlsx)。由此获得公司名称数组,数据存储在./tempdata/originCompanyData.txt

3、运行命令 phantomjs step3_getLinks.js(有时候会出现无法获取数据,一直在等待状态,未知原因,等待较长时间才会有反应,估计是天眼查响应慢) 通过公司名字,在天眼查上搜到与关键字相近的公司,取搜到结果的第一个公司的详情超链接 遍历查询所有需要搜索的公司 结果将得到一个超链接数组,数据存储在./tempdata/companyLinks.txt

4、运行命令 phantomjs step4_getDetails.js(有时候会出现无法获取数据,一直在等待状态,未知原因,等待较长时间才会有反应,估计是天眼查响应慢) 遍历超链接数组,获取各个公司的电话/邮箱/名字/网址等 此时数组还是一个文本存储方式,数据存储在./tempdata/companyDetails.txt

5、运行命令 node step5_changeFinalDataToXlsx.js 将文本数据格式转换成xlsx格式,数据存储在./result/finalCompanyData+时间戳.xlsx

收工!

phantomjs-tianyancha's People

Contributors

qingshanluoyue avatar

Stargazers

JinCheng Song avatar

Watchers

James Cloos avatar

Forkers

goto9ccc

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.