• 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: Chris <email@hidden>
  • Date: Wed, 23 Aug 2006 11:35:55 -0700

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

Thanks
-Chris

On Aug 23, 2006, at 6:10 AM, dev_sleidy wrote:

set tURL to "http://baseball.fantasysports.yahoo.com/b1/344356/standings"


set search_String01 to "<td class=\"team\"><a href="">

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: dev_sleidy <email@hidden>
References: 
 >Data from html table to excel (From: Chris <email@hidden>)
 >Re: Data from html table to excel (From: dev_sleidy <email@hidden>)

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