Created
February 27, 2018 23:01
-
-
Save lmon/40254e2c1f4565644b29e30d8890c917 to your computer and use it in GitHub Desktop.
verify some an urls
This file contains hidden or 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
| require 'curb' | |
| require 'json' | |
| urls = [ | |
| "/blog/21665-recipes-to-use-miso/an", | |
| "/blog/20423-joshua-fields-millburn-the-minimalists-rebecca-shern-minimal-wellness-interview/an", | |
| "/blog/21574-the-tunisian-lamb-stew-i-first-tasted-in-the-desert-recreated-at-home/an", | |
| "/blog/21574-the-tunisian-lamb-stew-i-first-tasted-in-the-desert-recreated-at-home/an", | |
| "/blog/21632-instant-stock-broth-hack-for-quick-braised-fish/an", | |
| "/blog/21224-an-interview-with-buffy-maguire-of-lady-falcon-coffee-club-about-blends/an", | |
| "/blog/21629-can-you-substitute-baking-soda-for-baking-powder-and-vice-versa/an", | |
| "/blog/21637-whats-your-signature-dish-change-the-way-you-cook/an", | |
| "/blog/21628-first-significant-purchases-to-make-house-feel-like-a-home/an", | |
| "/blog/21643-homemade-spinach-pasta-is-easier-than-you-think/an", | |
| "/blog/21637-whats-your-signature-dish-change-the-way-you-cook/an", | |
| "/blog/21612-kitchen-design-ideas-to-steal-from-celebrity-kitchens/an", | |
| "/blog/21490-global-breakfast-sandwiches/an", | |
| "/blog/21643-homemade-spinach-pasta-is-easier-than-you-think/an" | |
| ] | |
| def valid_json?(json) | |
| JSON.parse(json) | |
| return true | |
| rescue JSON::ParserError => e | |
| return false | |
| end | |
| baseurl = "http://local.food52staging.com:3000" | |
| urls.each do |url| | |
| http = Curl.get(baseurl + url) | |
| if http.response_code != 200 | |
| puts http.response_code | |
| puts baseurl+url +"\n" | |
| end | |
| if http.response_code == 200 | |
| if !valid_json?(http.body_str) | |
| puts 'INVALID JSON' | |
| puts baseurl+url +"\n" | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment