Jump to content

Need help with getting properties for _IELinkGetCollection


Recommended Posts

================================

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IE_Example("basic")
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
For $oLink In $oLinks
$sTxt &= $oLink.href & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)
================================

How do I find out what the other properties are?

i.e.  $oLink.href

href is a property that the script is looping through. How do I find what other properties exist ? ( I'm interested in correlating the text/image for each href, how do I find out what the name of the property for the text is?

Thanks,

Van

Link to post
Share on other sites

I would suggest Chrome, or Firefox (IE can work too, but there's too much clicking).

Chrome, Firefox:
Open a page you're interested in inside Firefox or Chrome, right mouse click on the link you're interested in, and then click INSPECT ELEMENT, and you'll see all properties of that link.

As for IE:

Open a page you're interested in, press F12 (OR click the "gear" icon, and then click on "F12 Developer tool"), Click the "arrow"-looking icon in the toolbar of the new Developer Tool window, and then click on the link you're interested in inside IE window. On the right side of the Developer tool window, click "Attributes", "Style".. or whatever you're interested in to see the properties.

Link to post
Share on other sites

Yup:

 

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

$oIE = _IECreate()

Local $sHTML = '<html><body><img src="http://aut1.autoit-cdn.com/site/wp-content/themes/TheCorporation/images/logo@2x.png" width="210" height="72" alt="AutoItScript" id="logo" /></body></html>'
_IEBodyWriteHTML($oIE, $sHTML)

Local $RetArray[1][2]

Local $OneImage = _IEGetObjById($oIE, 'logo')
If IsObj($OneImage) Then
    Local $AttrObj = $OneImage.attributes
    If IsObj($AttrObj) Then
        Local $TotalNumberOFAttr = $AttrObj.length
        For $i = 0 to $TotalNumberOFAttr-1
            Local $PropertyName = $AttrObj.item($i).nodeName
            Local $PropertyValue = $AttrObj.item($i).nodeValue
            If $PropertyValue <> '' Then _ArrayAddEx($RetArray, $PropertyName, $PropertyValue)
        Next
    EndIf
EndIf

_ArrayDisplay($RetArray)

_IEQuit($oIE)

Func _ArrayAddEx(ByRef $__Array, $value1, $value2)
    ReDim $__Array[UBound($__Array)+1][2]
    $__Array[0][0] = UBound($__Array)-1
    $__Array[UBound($__Array)-1][0] = $value1
    $__Array[UBound($__Array)-1][1] = $value2
EndFunc
Edited by dragan
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By walec
      Hey
      I have problem with Set Value for control slider on webside.
      Anyone have any idea for a solution?
       
      I tried but it doesn't work.
      Local $Strength = _IEGetObjById($oIE_Strona, "strength_value") Local $oText = _IEFormElementGetObjByName($Strength, "valuee") _IEFormElementSetValue($oText, "6") or
      _IENavigate ($oIE_Strona, "https://guantanamo.prisonwarsonline.com/gym/") Local $oDiv = $oIE_Strona.Document.GetElementByID("strength_value") Local $oAttribute = $oDiv.getAttribute("valuee") If IsObj ( $oAttribute ) Then $oAttribute.value = "6" EndIf Best Regards
    • By Mariog2000
      I've tried for a few days to simply open a url in IE and click an IE object that I can't "TAB" to and don't want to use a mouse-click if at all possible.  I've read up on things like using IEAction and IETagNameGetCollection to find the object but not smart enough to figure out how that works with my url or how to tell if my url is "basic" or a "form", "frameset", "iframe", etc.
      The other problem is I've tried using the "Run" and "ShellExecute" commands to open the browser, which works, but it opens it in a way that doesn't include my currently logged in user account.  For example, if I just click IE or Chrome for that matter and open my default homepage of google, the page that opens knows I'm logged in.  When I use "Send" "ShellExecute" or "_IE_Create" they always open pages generically which would require a login.
      So questions are, if I have a URL I'm trying to open, that's passes the currently logged on users credentials when opening the page (no clue where that happens)
      1.  Are there any code examples someone is willing to share that opens my IE maximized, with logged in credentials, and
      2.  Once that works, can someone suggest a technique a non-developer can find which IE Objects I need to send a "click" to so it opens the correct menu, pop-up, url, etc., associated with that object.  I've copied what doesn't work and sure I'm way off but it's not for a lack of effort. I'll keep trying and post updates but not looking good 🙂
      #include <IE.au3>
      Call ("selection")
      Func selection ()
      Global $oIE = _IECreate ("https://internal-webpage.aspx")
      Local $selectid = _IEGetObjByName ($oIE, "signageNo")
      Local $button = _IEGetObjByName ($oIE, "GO")

      _IEFormElementOptionSelect ($selectid, "3")
      _IEAction ($button,"click")
      EndFunc
      #include <IE.au3> Call ("selection") Func selection () Global $oIE = _IECreate ("https://internal-webpage.aspx") Local $selectid = _IEGetObjByName ($oIE, "signageNo") Local $button = _IEGetObjByName ($oIE, "GO") _IEFormElementOptionSelect ($selectid, "3") _IEAction ($button,"click") EndFunc 1. 
    • By zuladabef
      I want to set the value of a input, but I only have the input name and input id.  I cannot find a form in the source.  Form collection does not return any results.  
      Is there a way to use FormElementSetValue without a form name? Can I use _IEGetObjByName or _IEGetObjById?  If so, how do I set the value once I have the object? Where do I go from here? Local $oIE = _IEAttach("[Website Goes Here"]) Local $oForm = _IEFormGetCollection($oIE, 1) Local $oQuery = _IEFormElementGetCollection($oForm, 4) _IEFormElementSetValue($oQuery, "Set it to this")  
    • By Seminko
      Hey there,
      below function returns an "object collection" (not sure if that's the correct term) of 'a' elements grabbed from within //*[@id="J_DetailMeta"].
      However, I need the returned collection not to include objects with 'aria-disabled = true'. Is there a way of removing specific objects from such a collection?
      Func GetObjectList($sPicker) $oDetailMeta = _IEGetObjById($oIE, "J_DetailMeta") If Not @error Then $tags = $oDetailMeta.GetElementsByTagName("ul") For $tag in $tags $data_ID_value = $tag.GetAttribute("data-property") If $sPicker = "color" Then If $data_ID_value = '????' Or $data_ID_value = "????" Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "network" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf ElseIf $sPicker = "storage" Then If $data_ID_value = '????' Then $oReturnList = $tag.GetElementsByTagName("a") EndIf EndIf Next EndIf Return $oReturnList EndFunc $oColorList = GetObjectList("color") For $oColor In $oColorList If StringInStr($oColor.GetAttribute("aria-disabled"), "true") <= 0 Then ; remove object from the collection ??? EndIf Next  
    • By Kidney
      Hey guys,

      So we recently moved our company Knowledge Base to an in-house solution rather than paying a monthly subscription for someone else to host it and use their features. Either way, we have moved from one KB (Knowledge Base) site to another but there is an issue. No one restricted access to the original KB site which meant anyone was able to edit the site as they pleased. This means that some of the old KB's  features (picture/video/internal links) are still be utilized and I need to find out which pages have links that inevitably go dead once we stop sending them money. 

      So, I feel like in 90% of the way to getting this working correctly. Steps are fairly simple:
      Log into the KB Load a list of URL's Pull the HTML and search for "helpjuice" Log the URL has been checked Check for links on this page and check it against the list of URL's Log any new URL's that are missing from the list Now, I have no idea if this is the best way of doing this process but, again, I've made it 90% of the way so far and I would like to figure this specific problem out and if anyone has a better/more effective method of doing this, please point me in the right direction!

      Here is the Code i have so far.
      #include <File.au3> #include <FileConstants.au3> #include <WinAPIFiles.au3> #include <IE.au3> #include <MsgBoxConstants.au3> #include <Array.au3> Global $aGlobalLinks[1][3] = [["Link", "Checked", "Hit"]] ;Create Array with Headers ;//Load KB and login by submit the login form. Local $oIE = _IECreate ("https://website.com/kb/") Local $oForm = _IEFormGetObjByName($oIE, "login-form") Local $oEmail = _IEFormElementGetObjByName($oForm, "email") Local $oPassword = _IEFormElementGetObjByName($oForm, "password") _IEFormElementSetValue($oEmail, "email@email.com") _IEFormElementSetValue($oPassword, "password") Sleep(500) _IEFormSubmit($oForm) ;_IEQuit($oIE) ;//Load a second window to confirm it shows we are logged in. Grab a list of links as a jumping off point if the KB_URL.txt is empty ;//Mainly used for Debugging Local $oIE = _IECreate ("https://website.com/kb/") $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks _ArraySearch($aGlobalLinks, $oLink.href) If @error = 6 Then Local $aFill[1][3] = [[$oLink.href, "No", "No"]] _ArrayAdd($aGlobalLinks, $aFill) EndIf Next ;//Close second window of IE _IEQuit($oIE) ;//Attempt to load the KB_URL.txt LoadFile() ;//Setting $r to 1 since the txt file and the $aGlobalLinks will have a header in index 0 Global $r = 1 Do If $aGlobalLinks[$r][1] = "No" Then ;Skip Entries that have already been checked Local $oIE = _IECreate($aGlobalLinks[$r][0], 0, 1, 0) ;Create new window with the first 'unchecked' link entry _IELoadWait($oIE, 100, 2500) ;Wait 2.5 seconds for page to load If @error = 6 Then ;@error = 6 means the Timeout was met..Send {ESC} to stop the loading ConsoleWrite("Webpage timed out...Sending ESC..." & @CRLF) Send("{ESC}") Sleep(500) EndIf Local $sHTML = _IEDocReadHTML($oIE) ;Read the HTML and look for any trace of 'helpjuice' Local $result = StringRegExp($sHTML, ".*?helpjuice.*?", 0) ConsoleWrite("RegExt result: " & $result & @CRLF) If $result = 1 Then ;A result of 1 means there is a match $aGlobalLinks[$r][1] = "Yes" ;Set 'Checked' to 'Yes' $aGlobalLinks[$r][2] = "Yes" ;Set 'Hit' to 'Yes' ConsoleWrite("~~~~~~~~~~~~~ H I T ~~~~~~~~~~~~~ " & $aGlobalLinks[$r][0] & @CRLF) Else $aGlobalLinks[$r][1] = "Yes" ;Set 'Checked' to 'Yes' EndIf $oLinks = _IELinkGetCollection($oIE) ;Grab a list of links from the existing site ;_ArrayDisplay($oLinks) For $oLink In $oLinks ;Loop through all the links found and add any new links to the end of $aGlobalLinks ConsoleWrite("String: " & String($oLink) & @CRLF) ConsoleWrite("Looking for: " & $oLink.href & @CRLF) _ArraySearch($aGlobalLinks, $oLink.href) If @error = 6 Then Local $aFill[1][3] = [[$oLink.href, "No", "No"]] ;Set 'Checked' and 'Hit' to 'No' because this link has not been checked yet _ArrayAdd($aGlobalLinks, $aFill) EndIf Next _IEQuit($oIE) ;This next part is to reduce the amount times we write to the file ;Changing the '10' to '100' means the script will save the changes every 100 entries If IsInt($r/10) = 1 Then SaveFile() ConsoleWrite("File Saved: " & $r & "/" & UBound($aGlobalLinks) & @CRLF) EndIf ConsoleWrite("Completed " & $r & "/" & UBound($aGlobalLinks) & @CRLF) EndIf $r += 1 Until $r > UBound($aGlobalLinks) ;_ArrayDisplay($aGlobalLinks) Func SaveFile() $oFile = FileOpen(@ScriptDir & "\KB_URLs.txt", 2) FileClose($oFile) _FileWriteFromArray(@ScriptDir & "\KB_URLs.txt", $aGlobalLinks, 0, UBound($aGlobalLinks), ",") EndFunc Func LoadFile() _FileReadToArray(@ScriptDir & "\KB_URLs.txt", $aGlobalLinks, $FRTA_NOCOUNT, ",") _ArrayDisplay($aGlobalLinks) EndFunc  
      The error I'm getting has to do with the function _IELinkGetCollection. I used the examples in the AutoIT Help section and there is multiple uses of $oLink.href. I haven't been able to find much on when/how to use the .href.
      Here is the Console Output of the error:
       
      RegExt result: 0 Looking for: https://website.com/kb/ Looking for: https://website.com/kb/207557-abc-bank-homepage# Looking for: https://website.com/kb/ Looking for: https://website.com/kb/19011-partners-and-isos Looking for: https://website.com/kb/46470-onsite-install-partners Looking for: https://website.com/en/small-business/payments-and-processing/abc-merchant-services.html Looking for: https://website.com/Clover Looking for: https://website.com/screens/signup/?integrations_id=12345 Looking for: https://website.com/instruction/import-an-inventory-menu-spreadsheet/?userDevice=web Looking for: https://website.com/instruction/import-an-inventory-menu-spreadsheet/?userDevice=web Looking for: https://website.com/instruction/import-an-inventory-menu-spreadsheet/?userDevice=web Looking for: https://website.com/appmarket/apps/Z6GMBJ5HCBEQA?clientCountry=US Looking for: https://website.com/kb/207557-abc-bank-homepage#panel3a Looking for: https://website.com/kb/207557-abc-bank-homepage#panel4a Looking for: https://website.com/kb/207557-abc-bank-homepage#panel5a "C:\Users\Jon\Desktop\KB Scrub\HTMLDOC_Test.au3" (65) : ==> The requested action with this object has failed.: ConsoleWrite("Looking for: " & $oLink.href & @CRLF) ConsoleWrite("Looking for: " & $oLink^ ERROR Any insight is appreciated!
×
×
  • Create New...