用TypeScript开发爬虫程序
{ "compilerOptions": { "target": "ES6", "module": "commonjs", "noEmitOnError": true, "noImplicitAny": true, "experimentalDecorators": true, "sourceMap": false, // "sourceRoot": "./", "outDir": "./out" }, "exclude": [ "node_modules" ] } |
import superagent = require('superagent'); import cheerio = require('cheerio'); export const remote_get = function(url: string) { const promise = new Promise<superagent.Response>(function (resolve, reject) { |
import api = require('./api'); const go = async () => { let res = await api.remote_get('http://www.baidu.com/'); console.log(res.text); } go(); |
import api = require('./api'); import cheerio = require('cheerio'); const go = async () => { |
import api = require('./api'); import cheerio = require('cheerio'); const go = async () => { } |
export const wait_seconds = function (senconds: number) { return new Promise(resolve => setTimeout(resolve, senconds * 1000)); } |
import superagent = require('superagent'); import cheerio = require('cheerio'); export const get_index_urls = function () { export const remote_get = function (url: string) { const promise = new Promise<superagent.Response>(function (resolve, reject) { superagent.get(url) |
import api = require('./api'); import helper = require('./helper'); import cheerio = require('cheerio'); const go = async () => { |
import * as mongoose from 'mongoose';
mongoose.connect('mongodb://127.0.0.1/cnodejs_data', { // models |
interface IArticle { title: String; url: String; text: String; } export = IArticle; |
import mongoose = require('mongoose'); import IArticle = require('./IArticle'); interface IArticleModel extends IArticle, mongoose.Document { } const ArticleSchema = new mongoose.Schema({ const Article = mongoose.model<IArticleModel>("Article", ArticleSchema); |
import superagent = require('superagent'); import cheerio = require('cheerio'); import models = require('./models'); const Article = models.Article; export const get_index_urls = async function () { const $ = cheerio.load(res.text); } const $ = cheerio.load(res.text); } return new Promise<superagent.Response>((resolve, reject) => { |
import api = require('./api'); import helper = require('./helper'); import cheerio = require('cheerio'); (async () => { try { console.log('完毕!'); })(); |
用TypeScript开发爬虫程序的更多相关文章
- 爬虫浅谈一:一个简单c#爬虫程序
这篇文章只是简单展示一个基于HTTP请求如何抓取数据的文章,如觉得简单的朋友,后续我们再慢慢深入研究探讨. 图1: 如图1,我们工作过程中,无论平台网站还是企业官网,总少不了新闻展示.如某天产品经理跟 ...
- Scrapy:运行爬虫程序的方式
Windows 10家庭中文版,Python 3.6.4,Scrapy 1.5.0, 在创建了爬虫程序后,就可以运行爬虫程序了.Scrapy中介绍了几种运行爬虫程序的方式,列举如下: -命令行工具之s ...
- c# 获取网页的爬虫程序
转载于:https://www.cnblogs.com/wzk153/p/9145684.html HtmlAgilityPack相关详解: https://www.cnblogs.com/asxin ...
- 如何用TypeScript开发微信小程序
微信小程序来了!这个号称干掉传统app的玩意儿虽然目前处于内测阶段,不过目前在应用号的官方文档里已经放出了没有内测号也能使用的模拟器了. 工具和文档可以参考官方文档:https://mp.weixin ...
- 开发记录_自学Python写爬虫程序爬取csdn个人博客信息
每天刷开csdn的博客,看到一整个页面,其实对我而言,我只想看看访问量有没有上涨而已... 于是萌生了一个想法: 想写一个爬虫程序把csdn博客上边的访问量和评论数都爬下来. 打算通过网络各种搜集资料 ...
- TypeScript开发程序
使用TypeScript开发程序 简介 TypeScript一直发展不错,我们公司在开发新功能时,考虑到程序的可维护性,使用了TypeScript编写浏览器上的程序,我们是从零开始使用TypeScri ...
- ASP.NET 5系列教程 (五):在Visual Studio 2015中使用Grunt、Bower开发Web程序
基于Visual Studio 2015,你可以: 方便的管理前端包,如jQuery, Bootstrap, 或Angular. 自动运行任务,如LESS.JavaScript压缩.JSLint.Ja ...
- 使用Visual Studio Code搭建TypeScript开发环境
使用Visual Studio Code搭建TypeScript开发环境 1.TypeScript是干什么的 ? TypeScript是由微软Anders Hejlsberg(安德斯·海尔斯伯格,也是 ...
- python爬虫__第一个爬虫程序
前言 机缘巧合,最近在学习机器学习实战, 本来要用python来做实验和开发环境 得到一个需求,要爬取大众点评中的一些商户信息, 于是开启了我的第一个爬虫的编写,里面有好多心酸,主要是第一次. 我的文 ...
随机推荐
- Take advantage of “Integrated Calling” to know whom suspect talked to
A new feature in iOS 10 is "Integrated Calling". An integrated call from Chat App like Nav ...
- MacBook下如何安装mysql-python
解决方法: 先把之前装的卸载干净:pip uninstall mysql-pythonbrew uninstall mysql-connector-c 现在设置下mysql_config路径:首先修改 ...
- oracle中字符串连接用||
oracle中字符串连接用|| create or replace procedure testIf(idid number) is v_name stu.name%type; v_age stu.a ...
- O2O迈进智能时代 百度构建“服务生态”
经历过山车式资本市场后,O2O领域正努力摆脱“低门槛”,或将迎来技术创新之争.在刚刚落幕的百度世界大会上,百度副总裁.百度糯米总经理曾良宣布:将以百度糯米.手机百度和百度地图为核心构建百度服务生态.在 ...
- 『c++』 模板(template)--- 参数化多态性
---恢复内容开始--- 题外话: 模板机制的设计和细节是由Bjarne Stroustrup在其1988年10月发表的名为“Parameterized Types for C++”一文中披露的. 引 ...
- GPON和820.1p学习及资料(zt)
1)hw的两个PPT不错,GPON技术基础.ppt和10G-GPON技术基础.ppt, 介绍了GPON的知识背景,标准的名称,帧协议. 尤其是详细对比了10G-PON和G-PON的区别,以及演进的道路 ...
- Nginx启动报错: could not open error log file: open() &q
启动nginx报如下错误: nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error ...
- VUE 入门基础(5)
五,Class 与 Style 绑定 绑定HTML class 对象语法 我们可以传给v-bind:class 一个对象,以动态的切换class <div v-bind:class=" ...
- MySQL_采购入库价格与在线售价监控_20161213
c037采购入库价格与在线售价监控 ##c037采购入库价格与在线售价监控 SELECT a.城市,a.产品ID,a.商品名称,a.入库日期,a.入库仓库,a.单价,a.总金额,a.采购人,b.单价 ...
- JS原型和继承
//所有的函数都有一个prototype属性 function aa() { } console.info(aa.prototype); //这个prototype属性引用了一个对象,即原型,初始化时 ...