Results 1 to 5 of 5

Thread: A simple program to check if a webpage has been updated?

  1. #1
    Join Date
    Mar 2007
    Location
    Your Closet
    Beans
    380
    Distro
    Ubuntu 10.04 Lucid Lynx

    A simple program to check if a webpage has been updated?

    Description:
    A simple python script that when first run downloads a webpage for each url in a file, then each time after it's run checks the old file for changes. If there's a change detected it opens firefox! Execute the program with a "-v" option for more output.

    To setup the script from your bash terminal:
    mkdir ~/.checkurls; nano ~/.checkurls/checkurls.py
    Copy and paste the below code in the file and save it with ctl+x then y then Enter
    sed -i "s/\$USER/$USER/g" ~/.checkurls/checkurls.py
    Link to the file with sudo ln -s ~/.checkurls/checkurls.py /usr/bin/checkurls
    sudo chmod a+x /usr/bin/checkurls; nano ~/.checkurls/urls.txt
    Then enter some urls seperated by newlines into the file and you're done! It's not too hard, only takes a few seconds. n_n

    Script:
    Code:
    #!/usr/bin/env python
    import os, sys, urllib
    savepath = '/home/$USER/.checkurls/'
    
    errormsg = '%s: %s: No such file or directory'
    urlspath = savepath + 'urls.txt'
    for path in savepath, urlspath:
    	if not os.path.exists(path):
    		print errormsg % (__file__, path)
    		sys.exit(0)
    urlfile = open(urlspath, 'r').readlines(); urlstring = ''
    for url in urlfile:
    	if not 'http://' in url:
    		url = 'http://' + url
    	url = url.replace('\n', '')
    	filename = url.replace('/', '%2f')
    	if '-v' in sys.argv:
    		print '%s: %s ...' % (__file__, url)
    	if not os.path.isfile(savepath + filename):
    		urllib.urlretrieve(url, savepath + filename)
    	filelines = open(savepath + filename, 'r').readlines()
    	urllines = urllib.urlopen(url).readlines()
    	if not filelines == urllines:
    		open(savepath + filename, 'w').writelines(urllines)
    		urlstring += '"' + url + '" '
    
    if urlstring:
    	os.popen('firefox ' + urlstring)
    else:
    	if '-v' in sys.argv:
    		print '%s: nothing for today' % __file__
    Making the script run when your computer starts:
    Last edited by bashologist; May 2nd, 2007 at 05:39 PM.
    ...

  2. #2
    Join Date
    Mar 2007
    Location
    Your Closet
    Beans
    380
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: A simple program to check if a webpage has been updated?

    GTK-CHECKURLS(1)

    Manual:
    Code:
    GTK-CHECKURLS(1)                 User Commands                 GTK-CHECKURLS(1)
    
    NAME
           gtk-checkurls - check web pages for changes
    
    SYNOPSIS
           gtk-checkurls [ --check ] [ --edit ]
    
    DESCRIPTION
           Notify  the  user  when  a  web page changes to make their life easier. Keyboard
           shortcuts for managing URLs and the ability to add multiple URLs  simultaneously
           makes adding and editing very easy.
    
    OPTIONS
           -c --check
                  Check URLs.
    
           -e --edit
                  Edit URLs.
    
    AUTHOR
           Written by Ben Dover
    
    REPORTING BUGS
           Report bugs to <bashologist@gmail.com>.
    
    gtk-checkurls 1.5                  July 2007                   GTK-CHECKURLS(1)
    Tutorial1:
    Tutorial2:
    Included Files:
    Code:
    usr/
    usr/bin/
    usr/bin/gtk-checkurls.py
    usr/share/
    usr/share/menu/
    usr/share/menu/gtk-checkurls
    usr/share/man/
    usr/share/man/man1/
    usr/share/man/man1/gtk-checkurls.1.gz
    usr/share/applications/
    usr/share/applications/gtk-checkurls.desktop
    usr/share/pixmaps/
    usr/share/pixmaps/gtk-checkurls.png
    usr/bin/gtk-checkurls
    Attached Files Attached Files
    Last edited by bashologist; July 12th, 2007 at 05:44 AM.
    ...

  3. #3
    Join Date
    Oct 2008
    Beans
    17
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question Re: A simple program to check if a webpage has been updated?

    How do I get this script to run every ten minutes... I teach online and need to check message boards throughout the day.

    Sorry, I'm new to Ubuntu and linux. I managed to install this deb package and added the script to startup.

    Give details if you can...

    Any help appreciated.

  4. #4
    Join Date
    Jan 2007
    Beans
    128

    Re: A simple program to check if a webpage has been updated?

    Quote Originally Posted by Ter Rymon View Post
    How do I get this script to run every ten minutes... I teach online and need to check message boards throughout the day.

    Sorry, I'm new to Ubuntu and linux. I managed to install this deb package and added the script to startup.

    Give details if you can...

    Any help appreciated.
    Code:
    crontab -e
    type in the file:
    Code:
    */10 * * * * /path/to/script
    Refer to: http://en.wikipedia.org/wiki/Cron

  5. #5
    Join Date
    Jun 2007
    Beans
    379

    Re: A simple program to check if a webpage has been updated?

    Quote Originally Posted by Ter Rymon View Post
    How do I get this script to run every ten minutes... I teach online and need to check message boards throughout the day.

    Sorry, I'm new to Ubuntu and linux. I managed to install this deb package and added the script to startup.

    Give details if you can...

    Any help appreciated.
    Just to mention, if you're using firefox there's plugins that perform a similar duty. The one I'm currently using is called "Update Scanner". Give it a try, from the official addons.mozilla.com site, you may find it useful. Serves a slightly different purpose from this script here, may be more to your liking.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •