Jump to content

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. 

Link to comment
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
_ArrayDisplay($aTableData)

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
Share on other sites

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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

 

Link to comment
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

Link to comment
Share on other sites

  • 2 weeks later...

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

......aslfkjdslfkajsdflaj

CALL

1.111234

PUT

lsdkfjsaldkfjasf......

 

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.

Thanks

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...