Simply do:
'<head>' in msmalvo.read()
instead of:
msmalvo.read() == '<head>'
Question
i'm using urllib2
try:
msmalvo = urllib2.urlopen(website)
except URLError as e:
msmalvo = e
if msmalvo.code == 200:
if msmalvo.read() == '<head>':
print 'Exits!'
else:
print 'Don't exist'
else:
print ' '
print msmalvo.code, ':/'
the idea is to confirm that the string "\head/" was found in the source code of a page. How can I do this ?
Solution
Simply do:
'<head>' in msmalvo.read()
instead of:
msmalvo.read() == '<head>'