Jump to content

Help with IETableGetCollection


galpha
 Share

Recommended Posts

Hi,

I made a code to read some text that is located into tables in a IE page. The problem is, I can read anything except the text that is in bold that my big red arrow is pointing at. I tried to make a very detalied screenshot since I can't put the since it's passworded.

Posted Image

Source for one of the tables I can't get:

<HTML><HEAD><STYLE> /* No matching styles were found. */ </STYLE></HEAD><BODY><TABLE width="100%" border="0"><TBODY><TR><TD colSpan="7"><FONT size="1"> <STRONG>G-3030-Demande U/C sur poteau existant de l'usager</STRONG> </FONT></TD></TR></TBODY></TABLE></BODY></HTML>

My source code so far:

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

HotKeySet("/", "Traiter")
HotKeySet("{Esc}", "Quit")

While 1
Sleep(1000)
WEnd

Func Traiter()
$url = "Rapport DCT"
$oIE = _IEAttach($url, "Title")

$iBody = _IEBodyReadHTML($oIE)

$P30 = "P30: " & Call("CountSubs", $iBody, "P30") & Chr(9) & Chr(9)
$P35 = "P35: " & Call("CountSubs", $iBody, "P35") & Chr(9) & Chr(9)
$P40 = "P40: " & Call("CountSubs", $iBody, "P40") & Chr(9) & Chr(9)
$P45 = "P45: " & Call("CountSubs", $iBody, "P45") & Chr(9) & Chr(9)
$P50 = "P50: " & Call("CountSubs", $iBody, "P50") & Chr(9) & Chr(9)
$P55 = "P55: " & Call("CountSubs", $iBody, "P55") & Chr(9) & Chr(9)

$E30 = "E30: " & Call("CountSubs", $iBody, "E30") & Chr(10)
$E35 = "E35: " & Call("CountSubs", $iBody, "E35") & Chr(10)
$E40 = "E40: " & Call("CountSubs", $iBody, "E40") & Chr(10)
$E45 = "E45: " & Call("CountSubs", $iBody, "E45") & Chr(10)
$E50 = "E50: " & Call("CountSubs", $iBody, "E50") & Chr(10)
$E55 = "E55: " & Call("CountSubs", $iBody, "E55")

;A qui est le parc?
$Parc1 = Call("CountSubs", $iBody, "G :Bell Canada ")
$Parc2 = Call("CountSubs", $iBody, "G :Hydro Québec ")

;Vérifier le gestionnaire du parc:
If $Parc1 > 0 Then
    $gestionnaire = "Gestionnaire: Bell Canada" & Chr(10)
ElseIf $Parc2 > 0 Then
    $gestionnaire = "Gestionnaire: Hydro Québec" & Chr(10)
Else
    MsgBox(0, "Erreur", "Gestionnaire inconnu")
    $gestionnaire = "Gestionnaire: Inconnu" & Chr(10)
EndIf

;ToolTip($gestionnaire & $P30 & $E30 & $P35 & $E35 & $P40 & $E40 & $P45 & $E45 & $P50 & $E50 & $P55 & $E55, 0, 0, "",0)

;Section Test
$oTable = _IETableGetCollection($oIE, 5)
$aTableData = _IETableWriteToArray($oTable)
ToolTip($aTableData[0][0],0,0)
EndFunc

Func CountSubs($String, $Subs)
   Local $num = 0
   While 1
      $NewString = StringReplace($String, $Subs, "", 1)
      If $NewString == $String Then
         Return $num
      Else
         $String = $NewString
         $num = $num + 1
      EndIf
   Wend
EndFunc;==>CountSubs

Func Quit ()
Exit
EndFunc

I would love if someone could tell me how to get the elements from the red arrow in my pic.

Edited by galpha
Link to comment
Share on other sites

Based on the source you show containing <HTML> I'm guessing it's in an iFrame

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

_IEFrameGetObjByName

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

Sorry if I didn't reply, I wasn't home this week to try it. I got a bit into it and it seems it's not an IFrame (looking at the whole source, all the text are in <TD> and <TABLE> tags, no trace of <frame> or <iframe> text. Also, when I try to put the text of the array that should countain the bold text, it just puts me an empty MsgBox.

Is it because it's between <STRONG> tags that it doesn't recognize the <TD> tags?

Link to comment
Share on other sites

Nope, works great. Here's an example with your posted HTML:

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

$sHTML = ""
$sHTML &= "<HTML><HEAD><STYLE> /* No matching styles were found. */ </STYLE></HEAD><BODY>"
$sHTML &= "<TABLE width='100%' border='0'><TBODY><TR><TD colSpan='7'><FONT size='1'> "
$sHTML &= "<STRONG>G-3030-Demande U/C sur poteau existant de l'usager</STRONG> </FONT></TD>"
$sHTML &= "</TR></TBODY></TABLE>"
$sHTML &= "</BODY></HTML>"

$oIE = _IECreate()
_IEDocWriteHTML($oIE, $sHTML)

$oTable = _IETableGetCollection($oIE, 0)
$aData = _IETableWriteToArray($oTable, True)

_ArrayDisplay($aData)

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