用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来做实验和开发环境 得到一个需求,要爬取大众点评中的一些商户信息, 于是开启了我的第一个爬虫的编写,里面有好多心酸,主要是第一次. 我的文 ...
随机推荐
- MySQL 第九天(核心优化三)
一.昨天内容回顾 索引设计依据 与数据表有关系的sql语句都统计出来 where order by or等等条件的字段适当做索引 原则: 频率高的sql语句 执行时间长的sql语句 业务逻辑重要的sq ...
- Maven 笔记
maven DOS 打包命令:maven项目 cd 进入项目根目录执行 mav clean package;
- web基础知识小记
- mysql 模糊查询语句比较(LIKE、instr、locate、find_in_set、position)
大家都知道mysql 模糊查询的常用方法是LIKE 但这个语句查询效率很慢,那么有没有比较好的方法呢,下面本人测试了几个语句 测试数据800条左右 1,
- Parse the main function arguments
int main(int argc, char **argv) { std::string reportDir; std::string transURL; std::string visualEle ...
- js面向对象笔记
JavaScript 私有成员实现 到此为止,如果您任然对 JavaScript 面向对象持怀疑态度,那么这个怀疑一定是,JavaScript 没有实现面向对象中的信息隐藏,即私有和公有.与其他类式面 ...
- Easyui表单之下拉列表的三级联动
一.实现三级联动需要连接数据库 二.需要JSON数据的解析 三.需要Servlet类与界面相对应值的传递 1. 界面层需要的代码如下: <!DOCTYPE html> <html&g ...
- 研究SVM时安装的一些工具的方法
本文是个人存档,不介绍研究SVM相关内容. 1.bamboo在fedora19下 哪一行编译时报错,就注释掉 php插件不用装 提示ERROR: libcrfpp.so.0: cannot open ...
- sql 2012 操作EXCEL 2013
确认是否有Microsoft.ACE.OLEDB.12.0数据接口 --进行配置: EXEC sp_configure 'show advanced options', 1 GO RECONFIGUR ...
- 解决:jmeter查看结果树的响应数据提示超过最大值Response too large to be displayed
问题:用jmeter做接口测试时,查看结果树的数据没有显示全,给出下面的错误提示 Response too large to be displayed. Size: 1349830 > Max: ...