BrianTheLibrarian Posted July 18, 2017 Share Posted July 18, 2017 Hello I am trying to read a local html file using the following code: $tags = _IETagNameGetCollection ($oIE, "div") For $tag in $tags $class_value = $tag.GetAttribute("class") If $class_value = "info" Then $info = $tag.innertext EndIf If $class_value = "name" Then $author = $tag.innertext EndIf If $class_value = "license" Then $license = $tag.innertext EndIf Next FileWriteLine($file, "Data: "&$info & @TAB & $author & @TAB & $license & @TAB ) but it always writes a blank line for the filewriteline. Here is a sample html file that I wrote that still returns nothing. <HTML> <body> <div class="info"> Basic Information </div> <div class="name"> Username </div> <div class="license"> Selected License </div> </body> </html> Any ideas what I am doing wrong? Link to comment Share on other sites More sharing options...
Danp2 Posted July 18, 2017 Share Posted July 18, 2017 $class_value = $tag.GetAttribute("class") Does it work if you change this to the following? $class_value = String($tag.GetAttribute("class")) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danyfirex Posted July 18, 2017 Share Posted July 18, 2017 Hello. Try this: expandcollapse popup#include <IE.au3> Local $oIE = _IECreate() Local $sHTML=FileRead("test.html") ;your html file path here _IEDocWriteHTML($oIE, $sHTML) _IEAction($oIE, "refresh") Local $oInfo=_IEGetObjByClass($oIE,"info") Local $oName=_IEGetObjByClass($oIE,"name") Local $oLicense=_IEGetObjByClass($oIE,"license") ConsoleWrite("Info: " & _IEPropertyGet($oInfo,"innertext") & @CRLF) ConsoleWrite("Name: " & _IEPropertyGet($oName,"innertext") & @CRLF) ConsoleWrite("License=: " & _IEPropertyGet($oLicense,"innertext") & @CRLF) Func _IEGetObjByClass(ByRef $o_object, $s_Class, $i_index = 0) If Not IsObj($o_object) Then __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidDataType") SetError($_IEStatus_InvalidDataType, 1) Return 0 EndIf ; If Not __IEIsObjType($o_object, "browserdom") Then __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidObjectType") SetError($_IEStatus_InvalidObjectType, 1) Return 0 EndIf ; Local $i_found = 0 ; $o_tags = _IETagNameAllGetCollection($o_object) For $o_tag In $o_tags If String($o_tag.className) = $s_Class Then If ($i_found = $i_index) Then SetError($_IEStatus_Success) Return $o_tag Else $i_found += 1 EndIf EndIf Next ; __IEConsoleWriteError("Warning", "_IEGetObjByClass", "$_IEStatus_NoMatch", $s_Class) SetError($_IEStatus_NoMatch, 2) Return 0 EndFunc ;==>_IEGetObjByClass Saludos BrianTheLibrarian 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
BrianTheLibrarian Posted July 20, 2017 Author Share Posted July 20, 2017 Thanks Danyfirex! That did the job perfectly! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now