Jump to content

read tags from ie into excel


Recommended Posts

It all went well till I tried to get all the "ALT" tags - do I neet to change the included ie.au3 - from the include file and how?

#include <IE.au3>
Dim $avWin
Dim $oIE

While 1
    $avWin = WinList('[CLASS:IEFrame]')
   
    For $i = 1 To $avWin[0][0]
        If MsgBox(0x24, 'Choose window', 'Work with "' & $avWin[$i][0] & '"?') = 6 Then     ; Yes

            ExitLoop(2)
        EndIf
    Next
WEnd
$oIE = $avWin[$i][0]
$oIE = _IEAttach($avWin[$i][1], 'hwnd')
;$oIE = _IECreate ("www.ninemsn.com")
$oElements = _IETagNameAllGetCollection ($oIE)
$oExcel = ObjCreate("Excel.Application")
$oExcel.Visible = True
$oExcel.Workbooks.add
$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 1).Value = "Tag Name"
$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 2).Value = "Inner Text"
$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 3).Value = "outer Text"
$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 4).Value = "outerHTML"
$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 5).Value = "uniqueid"
$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 6).Value = "innerHTML"
;$oExcel.ActiveWorkbook.Sheets(1).Cells(1, 6).Value = "Type"
$RowNumber =2
For $oElement In $oElements
   $oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 1).Value = $oElement.tagname
   $oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 2).Value = $oElement.innerText
   $oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 3).Value = $oElement.outerText
   $oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 4).Value = $oElement.outerHTML
   $oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 5).Value = $oElement.uniqueid
   $oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 6).Value = $oElement.innerHTML
  ;$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 7).Value = $oElement.type
   $RowNumber = $RowNumber + 1
Next
msgbox (0x0,"finish box" ,"finished")
Link to comment
Share on other sites

Why not?

Also you can test if the "alt" objects have all:

For $oElement In $oArray

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 1).Value = $oElement.tagname

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 2).Value = $oElement.innerText

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 3).Value = $oElement.outerText

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 4).Value = $oElement.outerHTML

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 5).Value = $oElement.uniqueid

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 6).Value = $oElement.innerHTML

;$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 7).Value = $oElement.type

$RowNumber = $RowNumber + 1

Next

I think it dies at:

$oExcel.ActiveWorkbook.Sheets(1).Cells($RowNumber, 5).Value = $oElement.uniqueid as the ALT tag doesnt have .uniqueid

Try to addin the beggining of the code :

_IEErrorHandlerRegister ("MyErrFunc")

and at the end

Func MyErrFunc()

;$oError =$$oIEErrorHandler.description

Endfunc

Link to comment
Share on other sites

Everything has a uniqueid, by definition -- it is internally generated.

Your code worked in my test.

Try SciTe Debug mode and _IEErrorHandlerRegister() to try to get more information.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...