I am using jsdom, jquery and node.js to scrape websites. Is there any way I can post a form and get the resulting next page window using jsdom.
Here is the code
var httpAgent = require('http-agent'),
jsdom = require('jsdom'),
request = require('request');
request({uri:'http://www.orbitz.com'}, function(error, response, body){
if(error && response.statusCode != 200)
console.log('Error on request');
jsdom.env({
html: body,
scripts : [
'http://code.jquery.com/jquery-1.5.min.js'
]
}, function(err, window) {
var $ = window.jQuery;
$('#airOneWay').attr('checked', true);
$('#airRoundTrip').removeAttr('checked');
$('#airOrigin').val('ATL');
$('#airDestination').val('CHI');
// here we need to submit the form $('#airbotForm') and get the resulting window
//console.log($('#airbotForm').html());
});
});
This is the form which needs to be submitted $('#airbotForm')
and the resulting page has to be captured.
Can anybody help? Thanks