PHP script that monitors a list of URLs and notify me if a page has been updated

Posted on 2005-04-16
Last Modified: 2008-01-09
Hi guys, does it exist a PHP script that will notify me if a URL has changed (updated, modified) like the following:

given a list of links of websites I'm interested to follow and see the changes/updates, in example:

The list could be in a .txt file, or in a simple mysql db...

The script should to the following

1) list these links, so that I can click them

2) download the links (like if you open the link with your browser and "Save Page As..." > "Web Page, HTML only" but the PHP script should save it)

3) modify the filename, including e.g. the date and time in it. In example it the link is

it could save it as community.vugames.com_WebX?11@90.O2jSemUSn9j.10435135@.1dd962aa_2005.04.16_16.32.45
(the link name should be converted in a way that it works under linux, so the slashes could be converted in underscores and the “http:” could be removed…)

4) compare the last saved version with the version saved before (that's why having a date and time in the file is useful)

I don't know the perfect way of comparing to be able to say if a URL has been updated or not, but if it's a site without banners (or at least with a fixed tag like banner.gif, where the banner.gif rotates, but the html looks always the same) i think that comparing the file size is enough...

What I want to achieve is to see in a forum (a forum that has no auto-notification via e-mail) if new replies have been added to the thread, or if they have been modified by the authors...

5) if the 2 pages are different, the script should notify me, e.g. including a warning or icon near the link

6) an ideal thing would be to have an "history" link and see when the pages have been updated, so that if i accidentally click "refresh" 2 times I don't lose this information

7) the perfect thing would be that if there are updates there will be an added link that if I click I see what are the changes (like the output of the “diff” command under linux, something simple should be enough)

Do you know if there is already such a script elsewhere in the open source world?

If not, can you script the simplest solution to do what I mentioned above?

Thanks a bunch, 500 points if you do this ;)


Question by:firepol
    LVL 32

    Expert Comment

    There won't be any such script that matches all your requirements. You have to do of your own or hire a programmer.

    >> If not, can you script the simplest solution to do what I mentioned above?
    Sorry, We are neither interested nor allowed to do your homework at EE.
    LVL 2

    Author Comment

    >>There won't be any such script that matches all your requirements. You have to do of your own or hire a programmer.

    Ok... if no script like this exists I'll try to make my own.

    >>Sorry, We are neither interested nor allowed to do your homework at EE.

    I will post here some php code if i have some troubles doing some functions, maybe you would be interested to assist me in this case...
    LVL 2

    Author Comment

    Ah by the way I know it's impossible to find a script that meets ALL the requirements, but if you know some similar scripts that do a download of a URL and do a comparison, that would be a good start.
    LVL 6

    Expert Comment

    maybe you will have to use PEAR package Net_Monitor to do that, it is very flexible:
    also take a look on other monitor systems :
    LVL 9

    Accepted Solution

    You could always do the following.

    Read from the .txt file containing the urls to check...
    for() { // start at zero, go to the length of the file (urls)
          $url="<url from file, line>"; $dat=""; $dat[0]="";
          $file = @fopen($url, 'rb', 0); //open url, get the HTML output.
          if ($file){
                if ($fsize = @filesize($filename)){
                      $data = fread($file, $fsize);
                      while (!feof($file)){
                            $data .= fread($file, 1024);

          //open the old file, now check to see if it has changed from the previous save of the same url, assign $olddata to the contents of the old save
          if($olddata!=$data) {
                // save a file (you choose name, or base it upon url/time/whatever), with the $data as the content.

    This will save all your urls if they have changed from the previous content. Alternatively you could have it write to a new file so you can compared the two.

    You would need to have file reading and writing permissions on your folders. CHMOD them, or simply go into your control panel and do it. this is the easiest way I can think of right now.
    LVL 9

    Expert Comment

    Oh, also, add a mail() function if the file has changed if you want to be alerted via email.

    Make this a cronjob for ever 5 minutes or something if you want it to automatically check. Otherwise you can manually check.. great fun if there are many urls and/or you are on a slow connection.
    LVL 2

    Author Comment

    its not necessary that i create a cron, and the scriopt should not be completely automatic...

    it's ok that i will wisit the script.php simply when i want to see the updates, the script will check all the urls seimply when i run it, and he should check them only once...

    your for() function seems an infinite loop that would not be very appreciated by the web server admin...

    i'll try to see what i can do with your suggested code...
    LVL 9

    Expert Comment

    It was left blank on purpose.
    You need to make a script open the .txt containing urls, find how many there are and make this $urlcount, for example.
    Then use: for($i=0; $i<$urlcount; $i++) {
    LVL 14

    Expert Comment

    No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
    I will leave the following recommendation for this question in the Cleanup topic area:
    Accept: Vampireofdarkness {http:#13827344}

    Any objections should be posted here in the next 4 days. After that time, the question will be closed.

    EE Cleanup Volunteer

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now