{"id":73857,"date":"2017-02-07T13:45:25","date_gmt":"2017-02-07T13:45:25","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=73857"},"modified":"2017-02-07T13:45:25","modified_gmt":"2017-02-07T13:45:25","slug":"get-http-status-using-casperjs","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/","title":{"rendered":"How to get the HTTP status using CasperJS"},"content":{"rendered":"<p>You can get the HTTP status easily using CasperJS. To get HTTP status see the below script. For getting the HTTP status, firstly we will open the site for which we want to get the HTTP status and after that we will use the utils.dump() function.<br \/>\nThe utils module provides simple helper functions, some of them being very specific to CasperJS though. You can check the function references for utils module from CasperJS documentation link- <a href=\"http:\/\/docs.casperjs.org\/en\/latest\/modules\/utils.html\" target=\"_blank\">The utils module<\/a><br \/>\n<b>dump()<\/b> method is used to dumps a JSON representation of passed argument to the standard output.<\/p>\n<pre class=\"brush:js\">\/**\r\n* Webkul Software.\r\n*\r\n* @category Webkul\r\n* @package Webkul_CasperJS\r\n* @author Shikha Bhardwaj\r\n* @copyright Copyright (c) 2010-2017 Webkul Software Private Limited (https:\/\/webkul.com)\r\n* @license https:\/\/store.webkul.com\/license.html\r\n*\/\r\nvar casper = require('casper').create();\r\n    utils = require('utils'),\r\n    http = require('http'),\r\n    \r\n\r\ncasper.start();\r\n\r\ncasper.thenOpen('http:\/\/oc.webkul.com\/', function(response) {\r\n    utils.dump(response.status);\r\n    if (response == undefined || response.status &gt;= 400) this.echo(\"failed\", 'GREEN_BAR');\r\n});\r\n\r\ncasper.on('http.status.404', function(resource) {\r\n  this.echo('This url is 404: ' + resource.url, 'GREEN_BAR');\r\n});\r\n\r\ncasper.run(function() {\r\n  casper.exit();\r\n});\r\n<\/pre>\n<p>Now you have to run the command and you will get your result-<br \/>\n<b>casperjs file_name.js<\/b><\/p>\n<p>After executing the script, you can get the HTTP status. Refer to below screenshot for the same-<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-72276\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/02\/http-status.png\" alt=\"\" width=\"721\" height=\"177\" loading=\"lazy\" \/><\/p>\n<p>In case of 404 HTTP status, it will show like this-<br \/>\n<img decoding=\"async\" class=\"alignnone size-full wp-image-72276\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/02\/http.png\" alt=\"\" width=\"721\" height=\"177\" loading=\"lazy\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can get the HTTP status easily using CasperJS. To get HTTP status see the below script. For getting the HTTP status, firstly we will open the site for which we want to get the HTTP status and after that we will use the utils.dump() function. The utils module provides simple helper functions, some of <a href=\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":36,"featured_media":70767,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4313,4442,4443],"tags":[3505,4444,4445],"class_list":["post-73857","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-casperjs","category-get-http-status","category-http-status-using-casperjs","tag-casperjs","tag-get-http-status-using-casperjs","tag-http-status"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to get the HTTP status using CasperJS - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to get the HTTP status using CasperJS - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"You can get the HTTP status easily using CasperJS. To get HTTP status see the below script. For getting the HTTP status, firstly we will open the site for which we want to get the HTTP status and after that we will use the utils.dump() function. The utils module provides simple helper functions, some of [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-02-07T13:45:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Shikha Bhardwaj\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shikha Bhardwaj\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\"},\"author\":{\"name\":\"Shikha Bhardwaj\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/e44090b9dd8c2c58a3c78aa1d884c030\"},\"headline\":\"How to get the HTTP status using CasperJS\",\"datePublished\":\"2017-02-07T13:45:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\"},\"wordCount\":149,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png\",\"keywords\":[\"casperjs\",\"Get HTTP status using CasperJS\",\"HTTP Status\"],\"articleSection\":[\"CasperJS\",\"Get http status\",\"HTTP status using CasperJS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\",\"url\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\",\"name\":\"How to get the HTTP status using CasperJS - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png\",\"datePublished\":\"2017-02-07T13:45:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png\",\"width\":825,\"height\":260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get the HTTP status using CasperJS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/e44090b9dd8c2c58a3c78aa1d884c030\",\"name\":\"Shikha Bhardwaj\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8ada4c680b1ae3947314d3784bd12a6c5787f89723b2479a4261308bae1c1e0e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8ada4c680b1ae3947314d3784bd12a6c5787f89723b2479a4261308bae1c1e0e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Shikha Bhardwaj\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/shikha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to get the HTTP status using CasperJS - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/","og_locale":"en_US","og_type":"article","og_title":"How to get the HTTP status using CasperJS - Webkul Blog","og_description":"You can get the HTTP status easily using CasperJS. To get HTTP status see the below script. For getting the HTTP status, firstly we will open the site for which we want to get the HTTP status and after that we will use the utils.dump() function. The utils module provides simple helper functions, some of [...]","og_url":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-02-07T13:45:25+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png","type":"image\/png"}],"author":"Shikha Bhardwaj","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Shikha Bhardwaj","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/"},"author":{"name":"Shikha Bhardwaj","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/e44090b9dd8c2c58a3c78aa1d884c030"},"headline":"How to get the HTTP status using CasperJS","datePublished":"2017-02-07T13:45:25+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/"},"wordCount":149,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png","keywords":["casperjs","Get HTTP status using CasperJS","HTTP Status"],"articleSection":["CasperJS","Get http status","HTTP status using CasperJS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/","url":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/","name":"How to get the HTTP status using CasperJS - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png","datePublished":"2017-02-07T13:45:25+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/01\/casperjs.png","width":825,"height":260},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/get-http-status-using-casperjs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to get the HTTP status using CasperJS"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/e44090b9dd8c2c58a3c78aa1d884c030","name":"Shikha Bhardwaj","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8ada4c680b1ae3947314d3784bd12a6c5787f89723b2479a4261308bae1c1e0e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8ada4c680b1ae3947314d3784bd12a6c5787f89723b2479a4261308bae1c1e0e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Shikha Bhardwaj"},"url":"https:\/\/webkul.com\/blog\/author\/shikha\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/73857","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/36"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=73857"}],"version-history":[{"count":5,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/73857\/revisions"}],"predecessor-version":[{"id":73901,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/73857\/revisions\/73901"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/70767"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=73857"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=73857"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=73857"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}