I have a casper script that submits a form and scrapes the response.
Im trying to set up a "scraping on demand" environment where I can post the form values to a url using PhatomJS webserver, then use that data in my Casper script to scrape the page and then print out the response on the webpage. I don't see how I can pass the post variable into casper and then pass the response back to Phantom.
Heres my basic Phantom/Casper structure:
var server = require('webserver').create();
server.listen(8080, function(request, response) {
phantom.casperPath = '/source/casper/casperjs';
phantom.injectJs('/source/casper/casperjs/bin/bootstrap.js');
var address = request.post.address;
var casper = require('casper').create();
casper.start();
casper.then(function(){
address = // want to access global address here
result = begin(this, address); //Contians Casper scrape code
});
casper.run(function(){
this.exit();
});
response.statusCode = 200;
response.write(result); // from casper
response.close();
});
Is there any way to access the variables from phantom in casper, and then pass data back once I finish scraping?