Created
May 9, 2012 01:42
-
-
Save firedfox/2641033 to your computer and use it in GitHub Desktop.
document.links in phantomjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadPage(url ) { | |
/* Load a page and print out its links */ | |
var page = require('webpage').create(); | |
page.onLoadFinished = function (status) { | |
var links = page.evaluate(function() { | |
return [].join.call(document.links); | |
}).split(','); | |
console.log("Total links: " + links.length); | |
var workingLinks = 0; | |
for (i=0; i<links.length; i++) { | |
if(links[i] != null) { | |
console.log("Link " + i + " " + links[i]); | |
workingLinks++; | |
} | |
} | |
console.log("Working links " + workingLinks); | |
phantom.exit(); | |
}; | |
page.open(url); | |
} | |
loadPage("http://www.baidu.com/"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i want to find link inside link which is opened as a seprate page from index page and this process is going to run for all pages in website.
is there any solution???