checks URLs

This commit is contained in:
jose nazario 2016-01-02 16:37:42 -05:00
parent 29c2330667
commit 917ede49dd

19
awesome-check.py Executable file
View File

@ -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