title: How to check if the value on a website has changed
body: <p>Basically I'm trying to run some code (Python 3.2) if a value on a website changes, otherwise wait for a bit and check it later. </p>
  
  <p>First I thought I could just save the value in a variable and compare it to the new value that was fetched the next time the script would run. But that quickly ran into problems as the value was overwritten when the script would run again and initialize that variable.</p>
  
  <p>So then I tried just saving the html of the webpage as a file and then comparing it to the html that would be called on the next time the script ran. No luck there either as it kept coming up False even when there were no changes.</p>
  
  <p>Next up was pickling the webpage and then trying to compare it with the html. Interestingly that didn't work either within the script. BUT, if I type file = pickle.load( open( 'D:\Download\htmlString.p', 'rb')) after the script has run and then file == html, it shows True when there hasn't been any changes.</p>
  
  <p>I'm a bit confused as to why it won't work when the script runs but if I do the above it shows the correct answer.</p>
  
  <p>Edit: Thanks for the responses so far guys. The question I have wasn't really about other ways to go about this (although it's always good to learn more ways to accomplish a task!) but rather why the code below doesn't work when it's run as a script, but if I reload the pickle object at the prompt after the script has run and then test it against the html, it will return True if there hasn't been any changes. </p>
  
  <pre><code>try: 
      file = pickle.load( open( 'D:\\Download\\htmlString.p', 'rb'))
      if pickle.load( open( 'D:\\Download\\htmlString.p', 'rb')) == htmlString:
          print("Values haven't changed!")
          sys.exit(0)
      else:
          pickle.dump( htmlString, open( 'D:\\Download\\htmlString.p', "wb" ) )  
          print('Saving')
  except: 
      pickle.dump( htmlString, open( 'D:\\Download\\htmlString.p', "wb" ) )
      print('ERROR')
  </code></pre>