Can't parse html into a list using Applescript delimiters

I’ve been trying to extract weather from a webpage but I can’t get it to parse into a list.

set T to do shell script "curl \"http://m.weatheroffice.gc.ca/city/pages/ab-52_e.html\""

set d to AppleScript's text item delimiters

set AppleScript's text item delimiters to "Condition:"

return text item 2 of T

but I get this no matter what I use for the delimiter. Can anyone tell me what I am doing wrong? THANKS!

Hi,

this is exactly the expected result of your code

Some reasonable starting point might be:

set my_url to "http://m.weatheroffice.gc.ca/city/pages/ab-52_e.html"
get_conditions(my_url)

on get_conditions(the_url)
	set the_url to quoted form of the_url
	set T to (do shell script "curl " & the_url)
	
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to {"<dl class=\"table-currCond\">", "</dl>"}
	set r to text item 2 of T
	set AppleScript's text item delimiters to d
	set r to replace(" title=\"Wind Chill\"", r, "")
	set l1 to filter("<dt>", "</dt>", r)
	set l1 to items 1 thru -2 of l1
	log l1
	set l2 to filter("<dd>", "</dd>", r)
	set l2 to items 1 thru -2 of l2
	log l2
	return {l1, l2}
end get_conditions


on filter(start_tag, end_tag, text_val)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to end_tag
	set temp_list to every text item of text_val
	set AppleScript's text item delimiters to start_tag
	repeat with J from 1 to count temp_list
		try
			set item J of temp_list to text item 2 of item J of temp_list
		end try
	end repeat
	return temp_list
end filter


on replace(needle, haystack, new_val)
	set d to AppleScript's text item delimiters
	set AppleScript's text item delimiters to needle
	set temp_list to every text item of haystack
	set AppleScript's text item delimiters to new_val
	set r to temp_list as text
	set AppleScript's text item delimiters to d
	return r
end replace

It returns a list of two lists, one with keys the other with values.

Jürgen