I want to check http status code using casperjs. I have 500 links and I want to check status code of each link.
Asked
Active
Viewed 540 times
-1
-
We're not here to write code for you. Read the documentation and look for examples how to iterate over a list of URLs in CasperJS. – Artjom B. Aug 11 '15 at 09:13
-
possible duplicate of [CasperJS: Iterating through URL's](http://stackoverflow.com/questions/24360993/casperjs-iterating-through-urls) – Artjom B. Aug 11 '15 at 09:14
-
I have array with 500 links I am iterate using Casper.eachthen and checking status code for each link using thenOpen but after executing several links its became idle no further status code display, don't understand why its remain idle? – Akshay Padalkar Aug 11 '15 at 11:58
1 Answers
0
I hope this suggestion can fit you! In the very site of the official documentation there are some code examples for you to implement.
In your case, you can achieve this status control of 3 different ways:
Using resource.received
,resource.requested
or individually in each status control routine http.status.[code]
.
To work with resource.received
, you can see an example in this link.
To work with resource.requested
, you can see an example in this link.
To work with http.status.[code]
, you can see an example in this link.
I hope you can help you! See you later...

Diego Borges
- 342
- 3
- 7
-
Let us assume that we have 500 links. If any link is taking more than a certain amount of time to respond, we wish to skip to the next in the list.Can we set the timeout in page.resource.requested event. casper.then(function() { casper.on('page.resource.requested',function(requestData,request) { /* Can I set Timeout Here*/ }); casper.eachThen(links, function(response) { var finalURL = response.data; casper.thenOpen(finalURL, function(response) { console.log(finalURL); console.log("Status:::::",response.status) }) }) Please help me? – Akshay Padalkar Aug 21 '15 at 12:51
-
Do you want to treat your timeout BY REQUEST or FOR PAGE? By default, CasperJS timeout functions are for a complete requisition (page) ... but it is possible, within the resource.requested block, you put a waitFor function or use waitForResource. http://casperjs.readthedocs.org/en/latest/modules/casper.html#waitforresource – Diego Borges Aug 28 '15 at 12:55
-
as I have the array of links and checking status code of each link but in between the execution is ideal, I want to set a timeout so that if execution is ideal then the next link in the array will process for checking the status code – Akshay Padalkar Aug 31 '15 at 09:33
-