-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscraper.js
64 lines (57 loc) · 1.76 KB
/
scraper.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint-disable max-len */
const Apify = require('apify');
Apify.client.setOptions({ token: 'HPHxehsbm8m2t4iEvWpu8sFeJ' });
const axios = require('axios');
let data = '';
const config = {
method: 'get',
url: 'https://api.apify.com/v2/acts/pocesar~facebook-pages-scraper/runs/last/dataset/items?token=HPHxehsbm8m2t4iEvWpu8sFeJ\n',
headers: {
Cookie: 'AWSALB=CJFq9Ff621KPwyrNjrbVdikBoCaXzEvywP4PU+TEED2YEJEufiqiHIJAhSUBW2ms67c1AebTxKBUC07L49dZ7HKeF4wersmImyHNVpMN6MrtIYQc5iEteMxFCd1r; AWSALBCORS=CJFq9Ff621KPwyrNjrbVdikBoCaXzEvywP4PU+TEED2YEJEufiqiHIJAhSUBW2ms67c1AebTxKBUC07L49dZ7HKeF4wersmImyHNVpMN6MrtIYQc5iEteMxFCd1r',
},
data,
};
/*
Apify.main(async () => {
console.log('hello');
const run = await Apify.call('pocesar/facebook-pages-scraper', {
startUrls: [
{
url: 'https://www.facebook.com/TaylorSwift/',
},
],
language: 'en-US',
maxPosts: 10,
maxPostDate: '2019-01-01',
maxPostComments: 0,
maxCommentDate: '2020-01-01',
maxReviews: 0,
maxReviewDate: '2020-01-01',
proxyConfiguration: {
useApifyProxy: true,
},
});
console.log('Actor finished, here is the output:');
console.dir(run);
// console.log(hello);
});
*/
let values = '';
axios(config)
.then((response) => {
data = JSON.stringify(response.data);
const obj = JSON.parse(data)[0].posts;
// console.log(obj);
for (const each in obj) {
if (each) {
values += obj[each].postText;
}
}
console.log(values);
})
.catch((error) => {
console.log(error);
});
// get data from:
// https://api.apify.com/v2/acts/pocesar~facebook-pages-scraper/runs/last/dataset/items?token=HPHxehsbm8m2t4iEvWpu8sFeJ
// then we need to get postTest from each post, which is what we'll run through the IBM api