1
0
mirror of https://github.com/comatory/fb2iCal synced 2024-12-28 17:30:51 +01:00
Facebook-Events-iCal-Converter/lib/crawler.js

32 lines
702 B
JavaScript
Raw Normal View History

const request = require('request')
2019-10-15 09:22:08 +02:00
const useMobileURL = (originalURL) => {
const url = new URL(originalURL)
2019-10-15 09:22:08 +02:00
return `${url.protocol}//mobile.facebook.com${url.port}${url.pathname}${url.hash}`
}
2019-10-15 09:22:08 +02:00
const crawl = async (originalURL) => {
const url = useMobileURL(originalURL)
return new Promise((resolve, reject) => {
console.info(`Started request for URL: ${url}`)
request({
url,
headers: {
'Accept-Language': 'en-US, en',
'User-Agent': 'request',
},
}, (err, res, body) => {
if (err) {
reject(err)
return
}
2019-10-16 08:59:47 +02:00
console.info(`Finished request for URL: ${url}`)
resolve(body)
})
})
2019-10-15 09:22:08 +02:00
}
module.exports = crawl