用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来做实验和开发环境 得到一个需求,要爬取大众点评中的一些商户信息, 于是开启了我的第一个爬虫的编写,里面有好多心酸,主要是第一次. 我的文 ...
随机推荐
- es6 Class的继承extends & super
Class之间可以通过extends关键字,实现继承. 子类会继承父类的属性和方法. class Point { constructor(x, y) { this.x = x; this.y = y; ...
- 我现在的vimrc配置文件
runtime! debian.vim "设置编码 set encoding=utf- set fencs=utf-,ucs-bom,shift-jis,gb18030,gbk,gb2312 ...
- myeclipse中将整块的代码所选中的代码左右移动的快捷键
myeclipse中将整块的代码/所选中的代码左右移动的快捷键选择你要移动的代码,TAB 右移ctrl+TAB左移(我的使用Shift+TAB管用)要是不使用快捷键就是:选中代码,点击右键选中Shif ...
- Entity Framework技术导游系列 开篇 (转)
在微软平台写程序有年头了,随着微软数据存取技术的持续演化,我在程序中先后使用过ODBC.DAO.ADO.ADO.NET.LINQ to SQL. Entity Framework这些技术. 近几年来, ...
- LinQ的增删改查
全名:LinQ to sql类:集成化的数据访问类.会自动生成,进行数据库数据访问. LinQ的创建: 1.链接数据库:添加--添加新项--找到LINQ to SQL类--名字就叫数据库的名称就好. ...
- Go Data Structures: Interfaces
refer:http://research.swtch.com/interfaces Go Data Structures: Interfaces Posted on Tuesday, Decembe ...
- SQL日期格式,转自will哥
我之前一直認為 SQL Server 針對日期處理的函數不夠多(如果跟 MySQL 比較),尤其是處理日期欄位轉字串的時候,常常因為要輸出特定的格式而懊惱不已,常常一不小心就寫了一長串,很不易閱讀. ...
- python批量处理excel文件数据
https://www.zhihu.com/question/39299070?sort=created 作者:水中柳影链接:https://www.zhihu.com/question/392990 ...
- JavaScript prototype 使用介绍
用过JavaScript的同学们肯定都对prototype如雷贯耳,但是这究竟是个什么东西却让初学者莫衷一是,只知道函数都会有一个prototype属性,可以为其添加函数供实例访问,其它的就不清楚了, ...
- Linux下MySQL数据库常用基本操作 一
1.显示数据库 show databases; 2.选择数据库 use 数据库名; 3.显示数据库中的表 show tables; 4.显示数据表的结构 describe 表名; 5.显示表中记录 S ...