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.
Jan 16, 2016 🔴 Morning Jazz & Bossa Nova For Work & Study - Lounge Jazz Radio - Live Stream 24/7 Lounge Music 539 watching Live now.
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:
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?
JSON is very similar to plain JavaScript objects. Here is one:
You can directly require JSON in CasperJS (PhantomJS) like this:
And now you can use config.date
and config.url
in your script. You don't need assign those properties to dedicated variables, but of course you can do that to make the variables a little shorter: