Jump to content

Search the Community

Showing results for tags 'tag'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 2 results

  1. So in my time of coding I found a better, precise and more powerful way of finding element objects by classname and by tags. Its called querySelectorAll and it looks like this. Now I can forget needing to use a combination of _ietagnameget... and _iegetobjbyclassname... and just use one function. I have not tested this on the latest version of autoit, due to the many script braking changes, but I think it should still work. Credit to Dale Hohm who built the foundation of IE UDF and mLipok who made the error checking better on a previous post. DO note: This a relatively recent add-on to IE so it requires IE 9 and above. If you find you receive a com error of "unknown name" its likely the site is using meta tag attribute X-UA-Compatible which has reverted the browser to forget about it. Comments welcome ;#FUNCTION#============================================================================================================= ; Name...........: _IEquerySelectorAll() ; Description ...: Returns an Object or a Colection of objects ; Syntax.........: (ByRef $oDoc, $sQuery, $iItemIndex = Default) ; Parameters ....: $oDoc - The document object from IE ; $sQuery - String of Query. Example: _IEquerySelectorAll($oDoc, '"div.note, div.alert"', Default) will return a colection of div elements with classes of note and alert ; $iItemIndex - [optional] Default returns a colection, else use a 0 based index to indicate the object in sequence ; Return values .: Success - Object or a Colection of objects ; Failure - returns 0 sets the @error flag to non-zero. ; 3 ($_IEStatus_InvalidDataType) - Invalid Data Type ; 4 ($_IEStatus_InvalidObjectType) - Invalid Object Type ; 5 ($_IEStatus_InvalidValue) - Invalid Value ; 7 ($_IEStatus_NoMatch) - No Match ; Author ........: XThrax aka uncommon ; Remarks .......: This fuction was pretty much stolen from Dale Hohm the IE UDF creator so much credit to him, also to mLipok who made the error checking better. ; Also note that this a relatively recent add-on to IE so it requires IE 9 and above. ; If you find you receive a com error of "unknown name" its likely the site is using meta tag attribute X-UA-Compatible which has reverted the browser to forget about it. ; ; Related .......: _IETagNameAllGetCollection();_IEClassNameGetCollection() ; Link ..........;https://www.autoitscript.com/forum/topic/181376-_iequeryselectorall/ ; https://msdn.microsoft.com/en-us/library/cc304115(v=vs.85).aspx ; Example .......; No ; ===================================================================================================================== Func _IEquerySelectorAll(ByRef $oDoc, $sQuery, $iItemIndex = Default) If Not IsObj($oDoc) Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidDataType & " Invalid DataType" & @LF) Return SetError($_IEStatus_InvalidDataType, 1, 0) ElseIf Not __IEIsObjType($oDoc, "browserdom") Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidObjectType & " Invalid ObjectType" & @LF) Return SetError($_IEStatus_InvalidObjectType, 2, 0) ElseIf Not IsNumber($iItemIndex) And $iItemIndex <> Default Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidValue & " Invalid Index" & @LF) Return SetError($_IEStatus_InvalidValue, 3, 0) ElseIf $iItemIndex = Default Or $iItemIndex >= 0 Then Local $oTemp = Null If __IEIsObjType($oDoc, "documentcontainer") Then $oTemp = _IEDocGetObj($oDoc) ConsoleWriteError("--> _IEDocGetObj Error: " & @error & " Ext: " & @extended & @LF) If @error Then Return SetError(@error, @extended, 0) Else $oTemp = $oDoc EndIf Local $oClassColl = $oTemp.querySelectorAll($sQuery) If @error Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IESTATUS_GeneralError & " GeneralError1: " & @error & @LF) Return SetError($_IESTATUS_GeneralError, 3, 0) ElseIf (Not IsObj($oClassColl)) Or $oClassColl = Null Or $oClassColl.length = 0 Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_NoMatch & " NoMatch" & @LF) Return SetError($_IEStatus_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both Else If $iItemIndex = Default Then Return SetError($_IEStatus_Success, $oClassColl.length, $oClassColl) ElseIf $iItemIndex > $oClassColl.length Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidValue & " Invalid Value" & @LF) Return SetError($_IEStatus_InvalidValue, $oClassColl.length, 0) Else $oItem = $oClassColl.Item($iItemIndex) If @error Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IESTATUS_GeneralError & " GeneralError2: " & @error & @LF) Return SetError($_IESTATUS_GeneralError, 3, 0) ElseIf (Not IsObj($oItem)) Or $oItem = Null Then ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_NoMatch & " NoMatch Index: " & $iItemIndex & @LF) Return SetError($_IEStatus_NoMatch, 0, 0) ; Could be caused by parameter 2, 3 or both Else Return SetError($_IEStatus_Success, 0, $oItem) EndIf EndIf EndIf Else ConsoleWriteError("--> _IEquerySelectorAll Error: " & $_IEStatus_InvalidValue & " Invalid Value: " & $iItemIndex & @LF) Return SetError($_IEStatus_InvalidValue, 3, 0) EndIf EndFunc ;==>_IEquerySelectorAll
  2. Good Morning Everyone, Happy Tuesday (hopefully we all know it's Tuesday ) So, I hope I'm asking for the right thing here... I'm successfully able to find tag name "li" with attribute "class" and string "securityfix" 3 times in the given page... but I really don't know how to return the html code where the tags begin and finish. I'm trying to put together a patch table with fresh data - all good - nothing shady. This sure sounds like a regularexpression search or something of that nature... but you folks are the professionals so there may be a function out there that does exactly what I'm asking for. Been in the forums and most folks are just automating clicks and not creating new html pages like me. I've been using the help example "_IEDocWriteHTML" in my loops etc and so far so good... this one is NOT a table and most sites are... that's where I'm stuck. I don't want the extra html garbage of the page... just starting with those tags if possible... I might have already done this in the past but I can't remember LOL The IE.au3 has been amazing - thank you very much for making such a huge automation function. Thank you all for the help! #include <IE.au3> Call ("Gui01") Func Gui01() $URL01 = 'http://service.real.com/realplayer/security/en/' $oIE = _IECreate ($URL01, 0, 1) _IELoadWait($oIE) $oCorrectObj = "" $tags = $oIE.document.GetElementsByTagName("li") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "securityfix" Then $oCorrectObj = $tag MsgBox(0, "Security: ", "Security Fix Found :)") ;ExitLoop EndIf Next If IsObj ( $oCorrectObj ) Then MsgBox(0, "Security: ", "Yep - Exit loop") EndIF _IEQuit ($oIE)
×
×
  • Create New...