scraper script

endpointsharetweet
//jshint esversion: 6 const cheerio = require('cheerio'); const tonicExpress = require("notebook")("tonic/express-endpoint/1.0.0"); const app = tonicExpress(module.exports); const request = require('request'); const bodyParser = require('body-parser'); app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.post('/payload', function(req, res) { var employeeId = req.body.employeeId; var companyId = req.body.companyId; var options = { method: 'GET', url: 'https://my.insideview.com/iv/getExecutiveHoverInfo.iv?companyId=' + companyId + '&empId=' + employeeId, headers: { cookie: 'remember_me=2c90e7e644ad41370144b37859a4799e::aypp6yhdL4IQZ78WPwqhEDnAb0WecscZe0ZekyHvYqz9/l4Tqg17IOfvCg3QnDx4hPheUWPbUvBex/6QvhWkMAXfom2sQe1eyl5nwpQqQgoyDnouawowgwC7GrxKZDASV/a7HnTaGI0LUaOEtcJP73KjxWBWfFNeRKXVKYzxS0Ecs/gO77lzVooysbUIk624' }}; request.get(options, function(error, response, body) { if (error) console.error(error); var splitData = body.split('<div style="float:right;width:90px;text-align:right;">'); var $ = cheerio.load(splitData[0]); var name = $('a[class=head18darkgrey]').text().trim(); var title = $('b').text().trim(); var email = $('a[class=bluefont]').text().trim(); var object = {name: name, title: title, email: email}; res.json(object); }); });

no comments

    sign in to comment