I am in the process of writing a site scraper to grab some specific content from an ajax site without actual links, only with text that can be clicked. I have been using javascript for about a week now and have been using CasperJS since it cuts out a lot of work.
The problem I find is that I am writing several functions that all do the same thing, just find different links depending on the page. Therefore, I have:
function getLinks() {
var links = document.querySelectorAll('div.AjaxLink h3');
return Array.prototype.map.call(links, function(link) {
return link.innerText;
});
}
Its launch is carried out through:
casper.then(function() {
var myLinks = this.evaulate(getLinks);
});
It works great. I obviously don't want to have half a dozen functions that just have a different query string. So I want to do the following:
function getLinks(findText) {
var links = document.querySelectorAll(findText);
return Array.prototype.map.call(links, function(link) {
return link.innerText;
});
}
Then I try to run it through:
casper.then(function() {
var myLinks = getLinks('div.AjaxLink h3');
});
findText , , NodeList.
? , ?