Sunday, November 19, 2017

#1 2017-10-24 03:01:50 pm

MitchBVI
Member
Registered: 2006-02-14
Posts: 115

Recover Tables from a Web Site

Ever since Yahoo changed the ability to easily  download option chains I have been trying to write an Applescript to do the job. I seem to have got stuck on something I feel is simple. Using UI Browser I was able to get the correct sequence to the table I wanted but I the cannot paste it into something like Excel in fact t does not show as a string or text but the script compiles and completes. The following script fails at the last display dialog SelecteTable I have tried coercing the result as a string and text and they do not work either. What I want to do is paste the table "SelectedTable" into Excel. Any suggestions appreciated .

Applescript:

global SYM
global SelectedTable
tell application "Safari"
   display dialog "Enter Stock Symbol" default answer ""
   set SYM to text returned of result
   
   make new document with properties {URL:"https://finance.yahoo.com/quote/" & SYM & "/options?"}
end tell
delay 5

tell application "System Events"
   tell process "Safari"
       
       set SelectedTable to {select table 1 of group 9 of UI element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window 1}
       --display dialog SelectedTable
   end tell
end tell

Offline

 

#2 2017-10-24 04:49:21 pm

haolesurferdude
Member
Registered: 2010-02-19
Posts: 108

Re: Recover Tables from a Web Site

Try using a csv file downloaded from yahoo finance.  You'll need a list of the ticker symbols for each stock/fund you want separating each successive symbol from the preceding symbol with a plus sign (+).  The call is then

"http://finance.yahoo.com/d/quotes.csv?s=" & fundsList & "&f=snd1|1yr"

You can then manipulate the csv file any way you want.  Reading it into numbers or Excel, etc.

Last edited by haolesurferdude (2017-10-24 04:50:26 pm)

Offline

 

#3 2017-10-27 05:01:59 pm

MitchBVI
Member
Registered: 2006-02-14
Posts: 115

Re: Recover Tables from a Web Site

Thanks for taking the trouble to get back to me what you have suggested works fine for stocks in fact I already use something similar it but not for options. My tags are different to yours thats all and I then parse the data to Excel format in the download step.

If you have any idea about option chains that would be great.

Thanks

Peter

Offline

 

#4 2017-10-27 07:55:41 pm

haolesurferdude
Member
Registered: 2010-02-19
Posts: 108

Re: Recover Tables from a Web Site

Try Googling:

yahoo finance download option quotes



Two sites you might find useful are:
https://www.stock-data-solutions.com/kb … to-csv.htm
https://stackoverflow.com/questions/386 … inance-api

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)