I'm new to programing in languages more suited to the web, but I have programmed in vba for excel.
What I would like to do is:
- pass a list (in python) to a casper.js script.
- Inside the casperjs script I would like to iterate over the python object (a list of search terms)
- In the casper script I would like to query google for search terms
- Once queried I would like to store the results of these queries in an array, which I concatenate together while iterating over the python object.
- Then once I have searched for all the search-terms and found results I would like to return the RESULTS array to python, so I can further manipulate the data.
QUESTION --> I'm not sure how to write the python function to pass an object to casper.
QUESTION --> I'm also not sure how to write the casper function to pass an javascript object back to python.
Here is my python code.
import os
import subprocess
scriptType = 'casperScript.js'
APP_ROOT = os.path.dirname(os.path.realpath(__file__))
PHANTOM = '\casperjs\bin\casperjs'
SCRIPT = os.path.join(APP_ROOT, test.js)
params = [PHANTOM, SCRIPT]
subprocess.check_output(params)
js CODE
var casper = require('casper').create();
casper.start('http://google.com/', function() {
this.echo(this.getTitle());
});
casper.run();