MacUpdate Download Counter

Hey all, wrote this short script to check how many downloads a program has on macupdate.com
You simply enter the 5 digit id number in the programs URL
For example Play MiniTunes’s adress at macupdate is http://www.macupdate.com/info.php/id/22076
You simply type in 22076 and it shows you how many downloads it has.

Enjoy!!

set found to false
repeat until found = true
	set theURL to text returned of (display dialog "Please enter the program's unique 5 digit MacUpdate number." default answer "" default button 2)
	set theHTMLSource to (do shell script "curl " & "http://www.macupdate.com/info.php/id/" & theURL)
	
	(* Chop off all of the text before the number *)
	set AppleScript's text item delimiters to {"Downloads:</td><td class='value'>"}
	try
		set theHTMLSource2 to text item 2 of theHTMLSource
		if theHTMLSource2 is not equal to "" then
			set found to true
		end if
	on error
		display dialog "Application not found"
	end try
	
end repeat

(* Chop off all of the text after the number *)
set AppleScript's text item delimiters to {"<"}
set downloadcount to text item 1 of theHTMLSource2
(* Chop off all of the text before the number *)
set AppleScript's text item delimiters to {"<div class='prod_title'>"}
set source2 to text item 2 of theHTMLSource

(* Chop off all of the text after the number *)
set AppleScript's text item delimiters to {"<"}
set progname to text item 1 of source2

display dialog progname & return & "Downloads: " & downloadcount


here is an small update, so after you find your apps downloads you can either quit or search again.


repeat
	set found to false
	repeat until found = true
		set theURL to text returned of (display dialog "Please enter the program's unique 5 digit MacUpdate number." default answer "" default button 2)
		
		set theHTMLSource to (do shell script "curl " & "http://www.macupdate.com/info.php/id/" & theURL)
		
		(* Chop off all of the text before the number *)
		set AppleScript's text item delimiters to {"Downloads:</td><td class='value'>"}
		try
			set theHTMLSource2 to text item 2 of theHTMLSource
			if theHTMLSource2 is not equal to "" then
				set found to true
			end if
		on error
			display dialog "Application not found"
		end try
	end repeat
	
	
	(* Chop off all of the text after the number *)
	set AppleScript's text item delimiters to {"<"}
	set downloadcount to text item 1 of theHTMLSource2
	(* Chop off all of the text before the number *)
	set AppleScript's text item delimiters to {"<div class='prod_title'>"}
	set source2 to text item 2 of theHTMLSource
	
	(* Chop off all of the text after the number *)
	set AppleScript's text item delimiters to {"<"}
	set progname to text item 1 of source2
	
	set show to display dialog progname & return & "Downloads: " & downloadcount buttons {"Quit", "Next"} default button 2
	set choice to (button returned of show) as string
	if choice = "Quit" then
		exit repeat
	else
		set found to false
	end if
end repeat