# -*- coding: UTF-8 -*- def main(): source='/webdev/links-of-urls.txt'; destination=source+".result" check_urls(source, destination) print('done!') def check_urls(source, destination): with open(source, 'w') as fout: with open(source, 'r') as fin: for url in fin: pre="ERR" try: data = urllib2.urlopen(url.trim()).read() pre="OK" except: print("Failed...") fout.write(pre+" "+url) if __name__ == '__main__': main()
Leave a Reply