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 .

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

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.

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

Try Googling:

Two sites you might find useful are:
https://www.stock-data-solutions.com/kb/how-to-load-option-chains-from-yahoo-finance-to-csv.htm
https://stackoverflow.com/questions/38680008/how-can-i-download-option-tables-using-the-yahoo-finance-api