Python if statement not working as expected

Posted by Chris Esposito on Stack Overflow See other posts from Stack Overflow or by Chris Esposito
Published on 2010-04-23T16:29:49Z Indexed on 2010/04/23 16:33 UTC
Read the original article Hit count: 104

Filed under:
|

I'm searching for a string in a website and checking to see if the location of this string is in the expected location. I know the string starts at the 182nd character, and if I print temp it will even tell me that it is 182, however, the if statement says 182 is not 182.

Some code

f = urllib.urlopen(link)

 #store page contents in 's'
 s = f.read()
 f.close()
 temp = s.find('lettersandnumbers')

 if (htmlsize == "197"):
  #if ((s.find('lettersandnumbers')) == "182"):
  if (temp=="182"):
   print "Glorious"
   doStuff()
  else:
   print "HTML not correct.  Aborting."
 else:
  print htmlsize
  print "File size is incorrect.  Aborting."

© Stack Overflow or respective owner

Related posts about python

Related posts about if