Created
September 4, 2015 10:29
-
-
Save Aubreymcfato/e88d0813087b116ae0b7 to your computer and use it in GitHub Desktop.
Script for checking is a URL exists or is a dead link.
This file contains 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 requests | |
def exists(url): | |
r = requests.get(url) | |
print r.status_code | |
""" | |
if r.status_code == 200: #requests.codes.ok: | |
print "daje" | |
else: | |
print None | |
""" | |
#the list of URLs to check is on a file called prova_url. The file is just a list of urls, in column. | |
with open('prova_url', 'r') as urls: | |
for url in urls: | |
url=url.strip('\n') #prendendo dalla lista, piglia pure il \n | |
exists(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lo script è semplicissimo, ha solo bisogno in input di un file del tipo
Riproduce una lista di numeri, es.