-
Notifications
You must be signed in to change notification settings - Fork 0
/
CNNtest.js
50 lines (34 loc) · 813 Bytes
/
CNNtest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var request = require('request');
var cheerio = require('cheerio');
var express = require('express');
var app = express();
var url = [{
title : String,
link : String
}];
request('https://www.yahoo.com/news/us/', function(err,resp,body){
if(!err && resp.statusCode == 200){
var $ = cheerio.load(body);
//zn__column--idx-1
//console.log($);
$('a', '.js-stream-content').each(function(){
var url2 = $(this).attr('href');
var text2 = $(this).text();
url.push({
title : text2,
link : url2
});
console.log(url);
});
}
});
app.set('view engine', 'ejs');
app.get('/', function(req,res){
console.log(url.length);
console.log(url);
res.render('deleteLater', {url : url});
});
app.listen('3000', function(){
console.log('Listening on PORT 3000');
});
//