The big picture is to use Python to create a .txt file, then call the CasperJS script. Once the CasperJS script has run and saved its file (in this case the .png), have python grab that file and move to its next task.
As outlined in this question, another stack overflow question. I am looking primarily at the answer offered by Artjom B. towards the bottom. He suggests having Python save a .txt with the variables I would need, in my case (date, url) example, (2015-10-15, www.google.com)
I think part of my problem is I don't know much about JSON but I figure I would need to start by making both scripts, and then work on integrating them.
My Casper script is as follows:
var casper = require('casper').create({
pageSettings: {
loadImages: true, // The WebPage instance used by Casper will
loadPlugins: false // use these settings
}
});
var utils = require('utils');
var x = require('casper').selectXPath;
var fs = require('fs');
var url = //url provided in txt file that casper reads;
var date = //date provided in text file
casper.start().viewport(1920, 1080);
casper.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X)');
casper.thenOpen(url); //using the variable which came from the text file
casper.wait(3000, function () {
this.echo(this.getTitle());
console.log("Got title, now rendering image.");
this.capture('date.png'); //saving the file as the date, provided by the .txt file.
console.log("got image of home page :D")
});
casper.then(function () {
casper.exit();
});
casper.run();
I think that pretty much sums it up. Any direction on this is much appreciated, and any other links that you know of that can help me later down the road in running the Casper script inside a larger python script would be very helpful.
TLDR: How do I get CasperJS to read a text file, store the two values (date and url) as variables, and then use those variables to complete its job?