From 917ede49ddf17ee507806540e6697e6ef07a64cf Mon Sep 17 00:00:00 2001 From: jose nazario Date: Sat, 2 Jan 2016 16:37:42 -0500 Subject: [PATCH] checks URLs --- awesome-check.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 awesome-check.py diff --git a/awesome-check.py b/awesome-check.py new file mode 100755 index 0000000..2bfc921 --- /dev/null +++ b/awesome-check.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import re +import sys +import urllib2 + +with open(sys.argv[1], 'r') as f: + for line in f.readlines(): + if '](http' in line: + for url in re.findall("(http[s?]://[^)]+)", line): + # print url + try: + request = urllib2.Request(url) + request.get_method = lambda : 'HEAD' + resp = urllib2.urlopen(request) + if resp.getcode() != 200: + print 'ERROR - ', line + except urllib2.URLError, e: + print e, line \ No newline at end of file