• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Data from html table to excel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 09:10:45 -0400

I would like to create a applescript that would goto a website containing the current stats for my fantasy baseball league and copy those to a previously existing excel file.

[This post was unintentionally sent only to Chris; and, is re-posted here - with the 'set (value of cell 4 of row 3) to "Batting"' correction incorporated.]


Another way ...

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 tList to {}

set tText to do shell script "curl " & tURL

set tParagraphs to paragraphs of tText

set x to 1
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

  set x to x + 1
  if (x > 120) then exit repeat
 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"

-- 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)
 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)
  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


  • Follow-Ups:
    • Re: Data from html table to excel
      • From: Chris <email@hidden>
References: 
 >Data from html table to excel (From: Chris <email@hidden>)

  • Prev by Date: Re: Data from html table to excel
  • Next by Date: Internet Connect problem
  • Previous by thread: Re: Data from html table to excel
  • Next by thread: Re: Data from html table to excel
  • Index(es):
    • Date
    • Thread