I am creating a web scraping programme written in javascript, using request and cheerio. The webpage I'm trying to extract contains javascript within the html. It is the javascript that I'm interested in, however can't find a way to access it. Is there a way to extract the javascript, using cheerio?
Many thanks for any suggestions, I've just started with web scraping.
My code is:
var request = require('request');
var cheerio = require('cheerio');
var credentials = {
username: 'username',
password: 'password'
};
request.post({
uri: 'http://webpage',
headers: { 'content-type': 'application/x-www-form-urlencoded' },
body: require('querystring').stringify(credentials)
}, function(err, res, body){
if(err) {
callback.call(null, new Error('Login failed'));
return;
}
request('http://webpage', function(err, res, body)
{
if(err) {
callback.call(null, new
Error('Request failed'));
return;
}
var $ = cheerio.load(body);
var text = $('#element').text();
console.log($.html());
});
});