adamchapman Posted June 29, 2013 Share Posted June 29, 2013 I'm trying to change the timescale in the listbox at http://www.nasdaq.com/symbol/aa/historical , before downloading the data listed. I thought it would be possible to use _IEFormElementOptionselect, but looking at the source of the webpage the object doesn't appear to be in a form (it doesnt appear to be within any <form>, </form> brackets). html code looks like this for the listbox: <div class="historical-wrap"> <div class="historical-lookup-wrap"> <b style="display: inline;">Select the Timeframe:</b> <select id="ddlTimeFrame" name="ddlTimeFrame" onchange="getQuotes(false)"> <option value="5d">5 Days</option> <option value="1m">1 Month</option> <option value="3m" selected="selected">3 Months</option> <option value="6m">6 Months</option> <option value="1y">1 Year</option> <option value="18m">18 Months</option> <option value="2y">2 Years</option> <option value="3y">3 Years</option> <option value="4y">4 Years</option> <option value="5y">5 Years</option> <option value="6y">6 Years</option> <option value="7y">7 Years</option> <option value="8y">8 Years</option> <option value="9y">9 Years</option> <option value="10y">10 Years</option> </select> <p style="margin-bottom: none; display: inline;"> Get up to 10 years of daily historical stock prices & volumes.</p> </div> </div> Link to comment Share on other sites More sharing options...
adamchapman Posted June 29, 2013 Author Share Posted June 29, 2013 MY Autoit code so far looks like this: $oIE = _IECreate("http://www.nasdaq.com/symbol/aa/historical",0,0) $oSelect = _IEGetObjByID($oIE, "ddlTimeFrame") _IEAction($oSelect, "focus") _IEFormElementOptionselect ($oSelect, "5d" ) $oSelect.fireEvent("onchange") $oSelect.fireEvent("onclick") sleep(2000) $sText = _IEBodyReadHTML ($oIE) FileWrite("nasdaqtext.html", $sText ) but the html file written definitely does not contain a 5 day table Link to comment Share on other sites More sharing options...
Moderators Solution big_daddy Posted July 1, 2013 Moderators Solution Share Posted July 1, 2013 (edited) Solution provided by trancexx here. #include "Winhttp.au3" Local $sFilePath = @ScriptDir & "\HistoricalQuotes.csv" Local $sOut = DownloadThatThing("AA", "5d") If Not @error Then FileWrite($sFilePath, $sOut) ConsoleWrite("!ERROR = " & @error & @CRLF) Func DownloadThatThing($sSymbol, $sTimePeriod = "3m") ; Initialize and get session handle Local $hOpen = _WinHttpOpen() ; Get connection handle Local $hConnect = _WinHttpConnect($hOpen, "www.nasdaq.com") ; Fill the form (id of the form is -getFile-) Local $sHTML = _WinHttpSimpleFormFill($hConnect, "symbol/" & $sSymbol & "/historical", "getFile", _ "quotes_content_left_submitString", $sTimePeriod & "|true|" & $sSymbol) ; <- filling only this (thre rest is left default) Local $iErr = @error ; collect error ; Close handles _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Return whatever the result Return SetError($iErr, 0, $sHTML) EndFunc ;==>DownloadThatThing Edited July 1, 2013 by big_daddy Link to comment Share on other sites More sharing options...
adamchapman Posted July 1, 2013 Author Share Posted July 1, 2013 Wow thanks for your help, you and trancexx got a lot further than I did. Have you tested that method today? I keep getting "!ERROR = 1" and the csv file contains just a single zero. The code also takes 45 seconds to run before this failure. I'll try it again on another machine when I get home, in case it's a network issue Link to comment Share on other sites More sharing options...
adamchapman Posted July 1, 2013 Author Share Posted July 1, 2013 (edited) Just tried it on my home machine and it seems fine. Problems before must have been network limitations at my workplace. Thanks to both big_daddy and trancexx for working so hard just to help somebody like me. Really grateful for that. Adam Edited July 1, 2013 by adamchapman Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now