-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrape.js
34 lines (28 loc) · 814 Bytes
/
scrape.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
const express = require('express');
const cheerio = require('cheerio');
const request = require('request');
// var url = 'http://www.football-italia.net/106259/report-nainggolan-renews-roma';
// request(url, function (error, response, body) {
//
// var $ = cheerio.load(body);
// var content = $('.content');
// var contentText = content.text();
// console.log(contentText);
//
// });
exports.contentScrape = (url, cb) => {
request(url, (error, responce, body) => {
if (error){
cb({
error: error
});
}
let $ = cheerio.load(body);
let $url = url;
let $content = $('.content').text();
let contentText = $content
//respond with content value
// console.log('scraped from scraper.js', contentText);
cb(contentText);
});
};