Jump to content
Sign in to follow this  

Javascript number extraction

Recommended Posts

Im new to AutoIt and somewhat new to scripting. Im trying to gather information from a website (https://www.cedarfinance.com/trade/) but its running a javascript so the standard WindowInfo tool doesnt help. Im trying to extract the current stock cost and place it into an excel file every hour to get historical data. Since my knowledge of java is limited Im reaching out to anyone that may be able to provide me with guidance. 

Thanks in advance. 

Share this post

Link to post
Share on other sites

hi jimihendrix857

to extract data from a web page you could use the functions provided by the ie.au3 udf

for example:

_IETableGetCollection and _IETableWriteToArray

could be used on your link in this way:

#include <IE.au3>
#include <Array.au3>

; open the page
Local $oIE = _IECreate("https://www.cedarfinance.com/trade/")

Local $oTable = _IETableGetCollection($oIE, 2) ; second table contains values
Local $aTableData = _IETableWriteToArray($oTable, 1) ; put the list from web table to array

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post

Link to post
Share on other sites

No (intuitively) the IE UDF is for..IE. I believe there is a Chrome UDF, though I have never used it. Your best bet is to look at the IUAutomation UDF at the top of the Examples forum. I know you can work in Chrome with that.

Share this post

Link to post
Share on other sites

Snips & Scripts

My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ


Share this post

Link to post
Share on other sites

Do you have the site always open in your browser?

Then a easy way would be (using Autoit)

Activate the browser send CTRL +A then CTRL+C

then use a Regex to get the info you want.

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites

Thanks for everyones comments. The table extraction is perfect for that site. I have a 2nd site that doesn't have a clean table to extract but still in javascript.  Spotfn.com is the site.

The Regex solution is workable but not sure how to isolate a single number between two words and copy that into a variable. For example







How do I then place that into a variable?

It definitively gets what I want but I feel like there is a simpler way. I.e. pull the exact element from the site but even with the IU automation UDF I cant seem to isolate that particular element. Once I can learn to hunt down and know how to call a value from a specific element I can propagate the knowledge into the rest of my program. I would also like to click buttons in the javascript and unless I know the element name, the only way this can be done is through x, y mouse clicks which can get messed up.


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...