Python 2.7
Windows 10 x64
I have a .txt file full of soundcloud links and was wondering how I can use this txt file as input and loop through the links checking for the error that the header displays. And then printing those that do not give the error.
This what I have but it keeps giving me 404.
# Test Dead Link
# https://soundcloud.com/nightsanity-793590747/the-xx-intro
# Working Link
# https://soundcloud.com/madeleinepeyroux/everything-i-do-gonna-be-funky
import requests
filename = 'data.txt'
with open(filename) as f:
data = f.readlines()
for row in data:
r = requests.get(row)
r.status_code
if r.status_code == 404:
print 'The Link is Dead'
else:
print 'The Link is Alive'