Last active
December 19, 2015 00:29
-
-
Save vaidik/5869446 to your computer and use it in GitHub Desktop.
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
import json | |
import requests | |
import unittest | |
from time import time | |
def get_status_code(url): | |
response = requests.get(url, verify=False, allow_redirects=True) | |
return response.status_code | |
class TestGetStatusCode(unittest.TestCase): | |
def test_get_status_code(self): | |
urls = [ | |
"http://support.mozilla.org/kb/how-do-i-stop-websites-tracking-me", | |
"http://support.mozilla.org/kb/Private%20Browsing", | |
"http://support.mozilla.org/kb/Clear%20Recent%20History", | |
"http://support.mozilla.org/kb/Clear%20Recent%20History#w_how-do-i-remove-a-single-website-from-my-history", | |
"http://support.mozilla.org/kb/Site%20Identity%20Button", | |
"https://www.mozilla.org/en-US/plugincheck/", | |
"http://support.mozilla.org/kb/Options%20window%20-%20Security%20panel", | |
"https://www.mozilla.org/en-US/legal/privacy/firefox.html", | |
"http://www.mozilla.org/about/mission.html" | |
] | |
invalid_urls = 0 | |
for url in urls: | |
print 'Trying %s' % url | |
a = time() | |
if get_status_code(url) != requests.codes.ok: | |
invalid_urls += 1 | |
print ' Completed in: %.3f' % (time()-a) | |
self.assertEqual(invalid_urls, 0) | |
if __name__ == '__main__': | |
unittest.main() |
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
["http://support.mozilla.org/kb/how-do-i-stop-websites-tracking-me", "http://support.mozilla.org/kb/Private%20Browsing", "http://support.mozilla.org/kb/Clear%20Recent%20History", "http://support.mozilla.org/kb/Clear%20Recent%20History#w_how-do-i-remove-a-single-website-from-my-history", "http://support.mozilla.org/kb/Site%20Identity%20Button", "https://www.mozilla.org/en-US/plugincheck/", "http://support.mozilla.org/kb/Options%20window%20-%20Security%20panel", "https://www.mozilla.org/en-US/legal/privacy/firefox.html", "http://www.mozilla.org/about/mission.html"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment