0

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 ?

tohuwawohu
  • 13,268
  • 4
  • 42
  • 61
Milbol
  • 77
  • 7

1 Answers1

1

Simply do:

'<head>' in msmalvo.read()

instead of:

msmalvo.read() == '<head>'
Kabie
  • 10,489
  • 1
  • 38
  • 45