I just use the second case:
First: get the info stored in a globalInfo variable
var globalInfo;
casper.thenOpen("www.targetpage.cl/valuableInfo", function() {
globalInfo = this.evaluate(function(){
var domInfo = {};
domInfo.title = "this is the info";
domInfo.body = "scrap in the dom for info";
return domInfo;
});
});
Second: visit a page to store the captured data
casper.then(function(){
casper.thenOpen("www.mipage.com/saveIntheDBonPost.php", {
method: 'post',
data:{
'title': ''+globalInfo.title,
'body': ''+globalInfo.body
}
});
});
www.mipage.com/saveIntheDBonPost.php
takes the data in the $_POST
parameter and stores it to a DB.