Re: Data from html table to excel
Re: Data from html table to excel
- Subject: Re: Data from html table to excel
- From: dev_sleidy <email@hidden>
- Date: Wed, 23 Aug 2006 23:10:45 -0400
This works great, and I'm actually able to understand most of it.
Now how would I change it so it grabs the second table. I see the
String01 is the same in both tables. The second table does have a
different "table id" though. So I should be able to reference to
that??
set tURL to "http://baseball.fantasysports.yahoo.com/b1/344356/standings"
set search_String01 to "<td class=\"team\"><a href=\"/b1/344356/"
set search_String02 to "\">"
set search_String03 to "</a></td>"
set search_String04 to "<td class=\"stat\">"
set search_String05 to "</td>"
set search_String06 to "<td class=\"stat last\">"
set tList to {}
set tText to do shell script "curl " & tURL
set tParagraphs to paragraphs of tText
repeat with i in tParagraphs
if (i contains search_String01) then
set {oAStID, AppleScript's text item delimiters} to {AppleScript's
text item delimiters, search_String01}
set temp_String to last text item of i
set AppleScript's text item delimiters to search_String02
set temp_String to last text item of temp_String
set AppleScript's text item delimiters to search_String03
set temp_String to (first text item of temp_String) as string
set AppleScript's text item delimiters to oAStID
copy temp_String to end of tList
end if
if (i contains search_String04) then
set {oAStID, AppleScript's text item delimiters} to {AppleScript's
text item delimiters, search_String04}
set temp_String to last text item of i
set AppleScript's text item delimiters to search_String05
set temp_String to (first text item of temp_String) as string
set AppleScript's text item delimiters to oAStID
copy temp_String to end of tList
end if
if (i contains search_String06) then
set {oAStID, AppleScript's text item delimiters} to {AppleScript's
text item delimiters, search_String06}
set temp_String to last text item of i
set AppleScript's text item delimiters to search_String05
set temp_String to (first text item of temp_String) as string
set AppleScript's text item delimiters to oAStID
copy temp_String to end of tList
end if
end repeat
tell application "Microsoft Excel"
activate
if (not (document 1 exists)) then make new document -- Create a new
document, if needed.
-- Make enter titles, etc.
set (value of cell 4 of row 3) to "Batting"
set (value of cell 9 of row 3) to "Pitching"
set (value of cell 4 of row 19) to "Batting"
set (value of cell 9 of row 19) to "Pitching"
-- Enter statistics headings.
set column_titles to {"R", "HR", "RBI", "SB", "AVG", "W", "SV", "K",
"ERA", "WIP"}
repeat with i from 1 to (count column_titles)
set (value of cell (i + 1) of row 4) to (item i of column_titles)
set (value of cell (i + 1) of row 20) to (item i of column_titles)
end repeat
-- Dump the obtain team title and related statistics.
set x to 0
repeat with i from 5 to 16
repeat with j from 1 to ((count column_titles) + 1)
set (value of cell j of row i) to (item (j + x) of tList)
set (value of cell j of row (i + 16)) to (item (132 + j + x) of tList)
end repeat
set x to x + 11
end repeat
end tell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden