Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Check a webpage for change and notify.


  • Please log in to reply
3 replies to this topic
Sukarn
  • Members
  • 35 posts
  • Last active: Aug 16 2007 06:08 PM
  • Joined: 16 Jun 2007
I wrote this script to check a webpage every half an hour to see whether the registrations on a particular website had opened up. With help from engunneer in this thread I got the script working. You can use it to download the source code of a webpage ( HTML, PHP, etc.), check it for the presence / absence of something and then notify you accordingly.
I tried to make the script as easy as possibly to modify for your needs.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Persistent
#SingleInstance Force

CheckFor = Registrations are not open yet today.
CheckHere = http://www.example.com/path/register.php
SaveHere = E:\Source.txt
SaveTemp = E:\Test.txt
DisplayMessage = Registrations are open!`nGo Register now!
ElseMessage = Registrations are currently closed.
Contained = 0 ;Set to 0 if you want the messagebox to appear when CheckFor is absent. Set this to 1 if you want the messagebox when the sentence in "CheckFor" is present. Set to 2 if you want the message to appear when CheckFor is present and ElseMessage to appear when not present.

Settimer, Check, 1800000

Check:
{
	UrlDownloadToFile, %CheckHere%, %SaveHere%
	FileRead, V, %SaveHere%
	Loop, parse, V, `n, `r
	{
		If InStr(A_LoopField, CheckFor)
		{
			FileAppend, 1, %SaveTemp%
		}
	}
	FileRead, Status, %SaveTemp%
	If (Contained = "0")
	{
		If (Status = "1")
		{}
		Else MsgBox, %DisplayMessage%
	}
	Else If (Contained = "1")
	{
		If (Status = "1")
		{
			MsgBox, %DisplayMessage%
		}
	}
	Else If (Contained = "2")
	{
		If (Status = "1")
		{
			MsgBox, %ElseMessage%
		}
		Else MsgBox, %DisplayMessage%
	}
FileDelete, %SaveTemp%
FileDelete, %SaveHere%
}
return


Laszlo
  • Moderators
  • 4713 posts
  • Last active: Mar 31 2012 03:17 AM
  • Joined: 14 Feb 2005
It sounds really useful. Thanks for sharing it!

Sukarn
  • Members
  • 35 posts
  • Last active: Aug 16 2007 06:08 PM
  • Joined: 16 Jun 2007
Updated for more efficiency as suggested by engunneer.

iwillems
  • Members
  • 6 posts
  • Last active: Jul 29 2009 02:23 PM
  • Joined: 20 Jul 2009
Hi, I tried to modify this script a bit. I'm trying to get a messagebox when 'digitaleeditie' is in the sourcecode. The url is of a newspaper, which if the paper of today isn't yet available, will return a 404. Problem is, I tried replacing the adress and string, but I get a messagebox: 'Paper is online' even when it isn't. 'Digitaleeditie' is present in Source.txt. Any ideas?