Facebook-Events-iCal-Converter/lib/services/crawler.js

32 lines
535 B
JavaScript
Raw Permalink Normal View History

2019-10-23 20:37:06 +02:00
const request = require('request')
const crawl = async (url, { logger }) => {
if (logger) {
logger.log({
message: `Crawl started for url: ${url}`,
level: 'info',
service: 'parser',
})
}
2019-10-23 20:37:06 +02:00
return new Promise((resolve, reject) => {
request({
url,
headers: {
'Accept-Language': 'en-US, en',
'User-Agent': 'request',
},
}, (err, res, body) => {
if (err) {
reject(err)
return
}
resolve(body)
})
})
}
module.exports = crawl