By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Compare lists

P: 1
I'm trying to grab a list of items from a web page every day and look for changes since the day before. I should be able to work through grabbing the HTML each day, parsing out the list of items and then saving to a text file. However, I don't know how to approach the problem of comparing today's text file with yesterday's and determining which items that have been added or deleted.

Any hints to get me started would be greatly appreciated. Thanks.
Aug 23 '08 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,821
Heya, nnd6a.

You have a couple of options:
  • If the server is configured to support caching properly, you can check the last-modified header sent with the document.
  • Alternatively, you can hash the contents and see if the signature matches what you already have on file. E.g.,:

    Expand|Select|Wrap|Line Numbers
    1. $html = loadWebPage($url);
    2. if( sha1($html) != $yesterdaysSha1Hash )
    3. {
    4.   processHTML($html);
    5.   $yesterdaysSha1Hash = sha1($html);
    6. }
Aug 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.