Sign in to follow this  
Followers 0
William007

Help request for scraping table form IE window

5 posts in this topic

#1 ·  Posted (edited)

Hi all,

Impressed with site and available tools :whistle:

Could anyone assist me with this:

I try to scrape a table from uk.moneybee.net, a neat site that uses Fuzzy logic (like Seti@home) to predict stock price for next two weeks on limited nr of stock / indices. Now doing some research on how well price is predicted. 1e I want to write a table to a file, stripped from HTML code. Later I backtest the prediction with the actual stock price .. At first glance it shows positive results

For testing this script you need an account at moneybee (sorry for that) and login on the site. You dont need to install the screensaver or Neuralnet software, only if you want to participate in the project and keep using their data.

Than run the script..

Problems will show up: file remains empty, or get erros related to Array dimensions. tried Excel UDF, no results

Search this site extensively, but have not found the clue yet

Any idea how to get it to work? In return I share the outcome of the predictions in a week or 2-3.

Thanks in advance

William

; *******************************************************

; Before running: login at uk.moneybee.net

; Than run, go to Moneybee and scrape table, write to file

; *******************************************************

;

#include <IE.au3>

#include <Array.au3>

#include <file.au3>

#include <ExcelCOM.au3> >>>> Tried that, Array subscript problems !!!!!!!!!!!!!!!!!!!!!

$oIE = _IECreate()

_IENavigate($oIE,"http://uk.moneybee.net/mitglieder/prognosen_detail.asp?t=1")

; Fully body text shows to much text, only need table.

$sText = _IEBodyReadText ($oIE)

;MsgBox(0, "Body Text", $sText)

;_FileWriteLog("Text.log",$sText)

; Write Array to file

; NB no go with pictures in line with text !!!!!!!!!!!!!!!!!!!!!

; So search table 4 in page, thsi contains data I need

$oTable = _IETableGetCollection ($oIE,4)

$aTableData = _IETableWriteToArray ($oTable)

_ArrayDisplay($aTableData, "_ArrayDisplay() Test")

; Seem to need this, dont know why..!!!!!!!!!!!!!!!!!!!!!!!!!!

ReDim $aTableData[uBound($aTableData)+1]

; write array to file

_FileWriteFromArray("Text2.log", $aTableData, 1)

; File remains empty

Edited by William007

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$oTable = _IETableGetCollection ($oIE,4)

$aTableData = _IETableWriteToArray ($oTable)

_ArrayDisplay($aTableData, "_ArrayDisplay() Test")

; Seem to need this, dont know why..!!!!!!!!!!!!!!!!!!!!!!!!!!

ReDim $aTableData[uBound($aTableData)+1]

; write array to file

_FileWriteFromArray("Text2.log", $aTableData, 1)

; File remains empty

That ReDim is abusrd. What is in the array at the _ArrayDisplay() before the ReDim? Is it perhaps a 2D array? Are you blowing out the data by ReDim'ing it to a 1D array... Hmmm...?

If you are getting errors displaying a 2D array with _ArrayDisplay(), it means you are NOT running the current version of AutoIt. Download at least version 3.2.4.9 before you go on...

:whistle:

P.S. You may have to code a little loop to turn your 2D array into a string or a 1D array for writing to the file. I don't think _FileWriteFromArray() accepts 2D arrays.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

That ReDim is abusrd. What is in the array at the _ArrayDisplay() before the ReDim? Is it perhaps a 2D array? Are you blowing out the data by ReDim'ing it to a 1D array... Hmmm...?

If you are getting errors displaying a 2D array with _ArrayDisplay(), it means you are NOT running the current version of AutoIt. Download at least version 3.2.4.9 before you go on...

:whistle:

P.S. You may have to code a little loop to turn your 2D array into a string or a 1D array for writing to the file. I don't think _FileWriteFromArray() accepts 2D arrays.

Hi PsaltyDS

Thanks so far.

Running Autoit 3.2.4.9, upgraded it right over an older version

It is an 2D array, 2nd Column is empty. only Row 5 is the text I need. Could I simply delete the 2nd column and other rows ?

William

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi PsaltyDS

Thanks so far.

Running Autoit 3.2.4.9, upgraded it right over an older version

It is an 2D array, 2nd Column is empty. only Row 5 is the text I need. Could I simply delete the 2nd column and other rows ?

William

Then just FileWriteLine("Text2.log", $aTableData[5][0]). No need for all the fiddling if you know exactly where it is already. Perhaps you could put a test on it to be sure:

If (Ubound($aTableData, 0) = 2) and (Ubound($aTableData) >= 5) and ($aTableData[5][0] <> "") Then
     FileWriteLine("Text2.log", $aTableData[5][0])
Else
     MsgBox(16, "Error", "Invalid data from $aTableData.")
EndIf

:whistle:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Then just FileWriteLine("Text2.log", $aTableData[5][0]). No need for all the fiddling if you know exactly where it is already. Perhaps you could put a test on it to be sure:

If (Ubound($aTableData, 0) = 2) and (Ubound($aTableData) >= 5) and ($aTableData[5][0] <> "") Then
     FileWriteLine("Text2.log", $aTableData[5][0])
Else
     MsgBox(16, "Error", "Invalid data from $aTableData.")
EndIf

:lmao:

YEP ;)

Thats it, stupid of me not to try that option :whistle::P

Now it comes down to cleaning the text, like get the TABs and spaces right for importing it into Excel

Il keep u posted

Cheers, William

Edited by William007

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  
Followers 0