-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
23 lines (21 loc) · 814 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const axios = require('axios');
const hardmobUrl = 'https://www.hardmob.com.br/';
const url = `${hardmobUrl}/forums/407-Promocoes?s=&pp=30&daysprune=-1&sort=dateline&order=desc`;
const re = /<a class="title" href="(.*)">(.*)<\/a>/g;
axios.get(url, { responseType: 'arraybuffer', reponseEncoding: 'binary' })
.then(function (response) {
const data = response.data.toString('latin1');
const arrayUrls = data.match(re);
const clean = arrayUrls.map(function (htmlA) {
let data = /href="(.*)" (.*)>(.*)</g.exec(htmlA);
return {
title: data[3],
url: `${hardmobUrl}${data[1]}`,
};
});
console.log(JSON.stringify(clean));
})
.catch(function (error) {
console.log(error);
})
;