Jump to content

Possible to retrieve html into text file?


oemript
 Share

Recommended Posts

Referring to following link and image, I would like to know on whether it is possible to retrieve text and export them into text file using AutoIT or not.

URL : http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005

Does anyone have any suggestions?
Thanks in advance for any suggestions

 

5.png

Edited by oemript
Link to comment
Share on other sites

#include <IE.au3>
#include <File.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <TrayConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

_Example1()

Func _Example1() ;Temp Max/Min
    $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 0, 0, 1, 1)
    _IELoadWait($oIE)
    $oDoc = _IEDocReadHTML($oIE)
    $File = FileOpen('1.txt', 9)
    FileWrite($File, $oDoc)
    MsgBox(64 + 262144, 'Done', 'Check file')
    Exit
EndFunc   ;==>_Example1

Or this.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

If you only want the transactional logs you can use the following to place into an Array and then write the Array to file, I'll leave the latter to you.

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

Global $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 1)
_IELoadWait($oIE, 5000)
Global $otradeLog1 = _IEGetObjById($oIE, "tradeLog1")
Global $atradeLog1 = _IETableWriteToArray($otradeLog1, True)
Global $otradeLog2 = _IEGetObjById($oIE, "tradeLog2")
Global $atradeLog2 = _IETableWriteToArray($otradeLog2, True)

_ArrayDisplay($atradeLog1)
_ArrayDisplay($atradeLog2)

 

Link to comment
Share on other sites

10 hours ago, careca said:
Func _Example1() ;Temp Max/Min
    $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 0, 0, 1, 1)
    _IELoadWait($oIE)
    $oDoc = _IEDocReadHTML($oIE)
    $File = FileOpen('1.txt', 9)
    FileWrite($File, $oDoc)
    MsgBox(64 + 262144, 'Done', 'Check file')
    Exit
EndFunc   ;==>_Example1

I would like to know on where file is saved.

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

4 hours ago, Subz said:

If you only want the transactional logs you can use the following to place into an Array and then write the Array to file, I'll leave the latter to you.

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

Global $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 1)
_IELoadWait($oIE, 5000)
Global $otradeLog1 = _IEGetObjById($oIE, "tradeLog1")
Global $atradeLog1 = _IETableWriteToArray($otradeLog1, True)
Global $otradeLog2 = _IEGetObjById($oIE, "tradeLog2")
Global $atradeLog2 = _IETableWriteToArray($otradeLog2, True)

_ArrayDisplay($atradeLog1)
_ArrayDisplay($atradeLog2)

 

 Please see the linked image, the data cannot be export into text file.

510.png

Do you have any suggestions on what wrong it is?
Thanks, to everyone very much for any suggestions (^v^)

 

Edited by oemript
Link to comment
Share on other sites

Looks like you need to click the Full Transactional Log radio button

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

Global $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 1)
_IELoadWait($oIE, 5000)
Global $otradeLog = _IEGetObjByName($oIE, "charttype")
_IEAction($otradeLog, "click")
Global $otradeLog1 = _IEGetObjById($oIE, "tradeLog1")
Global $atradeLog1 = _IETableWriteToArray($otradeLog1, True)
Global $otradeLog2 = _IEGetObjById($oIE, "tradeLog2")
Global $atradeLog2 = _IETableWriteToArray($otradeLog2, True)

_ArrayDisplay($atradeLog1)
_ArrayDisplay($atradeLog2)

 

Link to comment
Share on other sites

10 hours ago, boomingranny said:

DirCreate("c:\temp") inetget("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005","c:\temp\stocks.txt") ShellExecute("c:\temp\stocks.txt")

Please see linked image, should it be used AutoIT coding as shown below?

The text file contains a lot of coding instead of data.

Would it be right approach to run your coding?

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

513.png

Link to comment
Share on other sites

3 minutes ago, Subz said:

Looks like you need to click the Full Transactional Log radio button

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

Global $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 1)
_IELoadWait($oIE, 5000)
Global $otradeLog = _IEGetObjByName($oIE, "charttype")
_IEAction($otradeLog, "click")
Global $otradeLog1 = _IEGetObjById($oIE, "tradeLog1")
Global $atradeLog1 = _IETableWriteToArray($otradeLog1, True)
Global $otradeLog2 = _IEGetObjById($oIE, "tradeLog2")
Global $atradeLog2 = _IETableWriteToArray($otradeLog2, True)

_ArrayDisplay($atradeLog1)
_ArrayDisplay($atradeLog2)

 

Would it be possible using a loop to load data until the end and insert into a single text file? such as D:\stock.txt

_ArrayDisplay($atradeLog1)
_ArrayDisplay($atradeLog2)

_ArrayDisplay($atradeLog3)

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

 

Link to comment
Share on other sites

9 hours ago, Subz said:

? Just use _ArrayWrite

I would like to know on how to click on the next page (red arrow) using AutoIT.

514.png

Do you have any suggestions?
Thanks, to everyone very much for any suggestions (^v^)

 

 

Edited by oemript
Link to comment
Share on other sites

Here is an example:

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

Global $bTradeLog = False, $aTradeLog
Global $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 1)
_IELoadWait($oIE, 5000)
Global $otradeLog = _IEGetObjByName($oIE, "charttype")
_IEAction($otradeLog, "click")
Global $odivlogNext = _IEGetObjById($oIE, "divLogNext")
While $odivlogNext.ClassName = "float_r pad0imp rel jshoverwithclass sel"
    _GetTradeLog()
    _IEAction($odivlogNext, "click")
    Sleep(100)
WEnd
;~ Get the last Transaction Log page.
_GetTradeLog()
_ArrayDisplay($aTradeLog)

Func _GetTradeLog()
    Local $otradeLog1 = _IEGetObjById($oIE, "tradeLog1")
    Local $atradeLog1 = _IETableWriteToArray($otradeLog1, True)
    Local $otradeLog2 = _IEGetObjById($oIE, "tradeLog2")
    Local $atradeLog2 = _IETableWriteToArray($otradeLog2, True)
    If $bTradeLog = False Then
        $aTradeLog = $atradeLog1
        _ArrayConcatenate($aTradeLog, $atradeLog2, 1)
        $bTradeLog = True
    Else
        _ArrayConcatenate($aTradeLog, $atradeLog1, 1)
        _ArrayConcatenate($aTradeLog, $atradeLog2, 1)
    EndIf
EndFunc

 

Link to comment
Share on other sites

Please see the following image, the working process is hidden, so I guess that the error occur on the last page, which next page button is missing.

TradeLog.png

Do you have any suggestions on whether it is the error source or not?
Thanks, to everyone very much for any suggestions (^v^)

 

 

 

Edited by oemript
Link to comment
Share on other sites

@oemript

First of all, which version of AutoIt are you using?

Then, adding a bit of error checking, will help you debug your code.

Example of error checking:

; Calling a function
_IEAttach(...)
If @error Then
    ConsoleWrite("Error while calling _IEAttach() function. Error: " & @error & @CRLF)
Else
    ; Continue the execution of the script
EndIf

Note that not every function returns an error code, so look at the Help file about the function you are going to call before error checking it in your script.

So, please, instead of posting pictures of your code, paste it directly in your post using the <code> tag :)

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

19 hours ago, oemript said:

I would like to know on how to click on the next page (red arrow) using AutoIT.

This works for me:

Global $ArrowNext = _IEGetObjById($oIE, "tsNext")
_IEAction($ArrowNext, "click")

 

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

4 hours ago, FrancescoDiMuro said:

@oemript

First of all, which version of AutoIt are you using? SciTE-Lite  Version 3.5.4

 

; Calling a function
_IEAttach(...)
If @error Then
    ConsoleWrite("Error while calling _IEAttach() function. Error: " & @error & @CRLF)
Else
    ; Continue the execution of the script
EndIf

 

 

 

I would like to know on what to contain inside IEAttach(???) under following case.

Furthermore, after testing coding, after MsgBox(16, "Main 2", 2) is displayed and going to _GetTradeLog(), the MsgBox(16, "Log 0", 0) does not display at all, which must be something wrong on call _GetTradeLog function after clicking 8 times.

Do you have any suggestions on what wrong it is?
Thanks, to everyone very much for any suggestions (^v^)

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

Global $bTradeLog = False, $aTradeLog
Global $oIE = _IECreate("http://www.aastocks.com/en/stocks/analysis/transaction.aspx?symbol=00005", 1)
$HWND = _IEPropertyGet($oIE, "hwnd")
WinSetState($HWND, "", @SW_MAXIMIZE)
_IELoadWait($oIE, 5000)
Global $otradeLog = _IEGetObjByName($oIE, "charttype")
_IEAction($otradeLog, "click")
Global $odivlogNext = _IEGetObjById($oIE, "divLogNext")
While $odivlogNext.ClassName = "float_r pad0imp rel jshoverwithclass sel"

    MsgBox(16, "Main 1", 1)
    _IEAction($odivlogNext, "focus")
    MsgBox(16, "Main 2", 2)
    _GetTradeLog()
    MsgBox(16, "Main 3", 3)

    Sleep(300)
    _IEAction($odivlogNext, "click")
    Sleep(500)
 WEnd
_ArrayDisplay($aTradeLog)
;~ Get the last Transaction Log page.
_GetTradeLog()
_IEQuit($oIE)
_ArrayDisplay($aTradeLog)
Local $sFilePath = "D:\stocks.txt"
_FileWriteFromArray($sFilePath, $aTradeLog, 1)
; Display the file.
ShellExecute($sFilePath)

Func _GetTradeLog()
      Local $sFilePath = "D:\stocks.txt"
      Local $otradeLog1 = _IEGetObjById($oIE, "tradeLog1")
      Local $atradeLog1 = _IETableWriteToArray($otradeLog1, True)
      Local $otradeLog2 = _IEGetObjById($oIE, "tradeLog2")
      Local $atradeLog2 = _IETableWriteToArray($otradeLog2, True)
      MsgBox(16, "Log 0", 0)
      If $bTradeLog = False Then
      MsgBox(16, "Log 1", 1)
      $aTradeLog = $atradeLog1
      MsgBox(16, "Log 2", 2)
        _ArrayConcatenate($aTradeLog, $atradeLog2, 1)
        MsgBox(16, "Log 3", 3)
        $bTradeLog = True
        MsgBox(16, "Log 4", 4)
     Else
        MsgBox(16, "Log 5", 5)
        _ArrayConcatenate($aTradeLog, $atradeLog1, 1)
        MsgBox(16, "Log 6", 6)
        _ArrayConcatenate($aTradeLog, $atradeLog2, 1)
      EndIf
      ;_ArrayDisplay($aTradeLog)
      MsgBox(16, "Log 7", 7)
      _FileWriteFromArray($sFilePath, $aTradeLog, 1)
      MsgBox(16, "Log 8", 8)

EndFunc

 

Edited by oemript
Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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