isolate multiple words in string

Hi,

I used the script:

do shell script "/usr/bin/curl " & quoted form of "http://www.fifa.com/worldfootball/index.html"

to get the text from a fifa web page. Now I need to extract the data from every row in the Latest Fixtures and Results. The text for every row is

“<tr class="odd"><td class="c">10.01.08<td class="c img"><a href="/associations/association=egy/index.html"><img class="flagSmall" width="19" height="13" src="/imgml/flags/s/egy.gif" alt="egypt" /><a href="/associations/association=egy/index.html">Egypt<td class="c res"> <td class="r"><a href="/associations/association=mli/index.html">Mali<td class="c img"><a href="/associations/association=mli/index.html"><img class="flagSmall" width="19" height="13" src="/imgml/flags/s/mli.gif" alt="Mali" />”

From this row I would need the bold words.

Thanks

gecko

Hi gecko,

q&d


set t to do shell script "/usr/bin/curl " & quoted form of "http://www.fifa.com/worldfootball/index.html"
set {TID, text item delimiters} to {text item delimiters, "Latest Fixtures and Results"}
set t to text item 2 of t
set text item delimiters to "All Fixtures and Results"
set t to text item 1 of t
set text item delimiters to "td class=\"c\">"
set v to text items of t
set text item delimiters to TID
set datelist to {}
repeat with i from 2 to count v
	set end of datelist to strip_text(item i of v)
end repeat
set text item delimiters to "/index.html\">"
set v to text items of t
set x to 1
set y to 1
set gameList to {}
repeat until y = (count v)
	if item y of v does not start with "<" then
		set end of gameList to item x of datelist & ": " & strip_text(item y of v) & " - " & strip_text(item (y + 1) of v)
		set y to y + 2
		set x to x + 1
	else
		set y to y + 1
	end if
end repeat
set text item delimiters to return
set gameList to gameList as text
set text item delimiters to TID
display dialog gameList

on strip_text(s)
	return text 1 thru ((offset of "<" in s) - 1) of s
end strip_text

Wow! I’m very impressed! It works perfectly. Would it also be possible to get the scores of the games already played?

A game already played row looks like this:

10.01.08\"qatar\"Qatar0:0Iran\"Iran\"

Thanks!

gecko

Here you are!


set t to do shell script "/usr/bin/curl " & quoted form of "http://www.fifa.com/worldfootball/index.html"
set {TID, text item delimiters} to {text item delimiters, "Latest Fixtures and Results"}
set t to text item 2 of t
set text item delimiters to "All Fixtures and Results"
set t to text item 1 of t
set text item delimiters to "td class=\"c\">"
set v to text items of t
set datelist to {}
repeat with i from 2 to count v
	set end of datelist to strip_text(item i of v)
end repeat
set text item delimiters to "/index.html\">"
set v to text items of t
set x to 1
set y to 1
set gameList to {}
repeat until y = (count v)
	if item y of v does not start with "<" then
		set theResult to ""
		if item y of v contains "strong" then set theResult to get_result(item y of v)
		set end of gameList to item x of datelist & ": " & strip_text(item y of v) & " - " & strip_text(item (y + 1) of v) & space & theResult
		set y to y + 2
		set x to x + 1
	else
		set y to y + 1
	end if
end repeat
set text item delimiters to return
set gameList to gameList as text
set text item delimiters to TID
display dialog gameList

on strip_text(s)
	return text 1 thru ((offset of "<" in s) - 1) of s
end strip_text

on get_result(r)
	set {TD, text item delimiters} to {text item delimiters, "<strong>"}
	set r to text item 2 of r
	set r to strip_text(r)
	set text item delimiters to TD
	return r
end get_result