Jump to content
Sign in to follow this  
uncommon

IE find a dynmic link

Recommended Posts

uncommon

So I have 2 links on a webpage, the txt can be anything, the href changes too but not the domain of link. I found that this.....

For $x = 0 To 164
Local $oInputs = _IETagNameGetCollection($oIE, "a", $x)
If StringInStr($oInputs.id, "ctl00_ctl00_ctl00_ctl00_ContentMain_ContentMain_ContentMain_ContentMain_TabContainer1_DetailsTab_DetailsController1_ctl00_ParcelSummary1_TitleSection") > 0 Then $ParcelID = $oInputs.href
Next

Is a crude way to find a link but it adds unnecessary seconds to the script. Is there a better way to find find these guys on the webpage? I mean a way to do with without looping through every possible link.

I would put the source of page but its long. Here is a link to an example.

Posted Image


No problem can withstand the assault of sustained thinking.Voltaire

_Array2HTMLTable()_IEClassNameGetCollection()_IEquerySelectorAll()

Share this post


Link to post
Share on other sites
Exit

The HREF of the link is the same as the URL in the address bar.

Addressbar: http://www.ocpafl.org/Searches/ParcelSearch.aspx/PID/312214078800170

Href-Link in the page: href="/Searches/ParcelSearch.aspx/PID/312214078800170"

If you click on the link, the same page shows again.

Why not take the addressbar data?

$ParcelID = _IEPropertyGet($oIE,"locationurl")
Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
tlman12

it appears to be a fairly simple webpage. could you get by with clicking the link by index?

it appears to be 18

_IELinkClickByIndex($oie,18)

Share this post


Link to post
Share on other sites
uncommon

@exit

The normal address is http://www.ocpafl.org/Searches/ParcelSearch.aspx it happed to change to the right link because I was testing it. Assume the address bar will be http://www.ocpafl.org/Searches/ParcelSearch.aspx. Any other solutions?

@tlman12

The website it turns out is kind of dynamic. A certain amount of links will appear under conditions I cant anticipate so a parse by index wont really work unless I look at every link and filter to what I am looking for but that takes extra time.


No problem can withstand the assault of sustained thinking.Voltaire

_Array2HTMLTable()_IEClassNameGetCollection()_IEquerySelectorAll()

Share this post


Link to post
Share on other sites
Exit

#include <IE.au3>
#include <String.au3>
;   sample URL $URL = "http://www.ocpafl.org/Searches/ParcelSearch.aspx/PID/312214078800170"
$URL = "http://www.ocpafl.org/Searches/ParcelSearch.aspx"
$oIE = _IECreate($URL)
MsgBox(262144, " ", "Please navigate to the desired page and then click OK", 0)
$oID = _IEGetObjById($oIE, "ctl00_ctl00_ctl00_ctl00_ContentMain_ContentMain_ContentMain_ContentMain_TabContainer1_DetailsTab_DetailsController1_ctl00_ParcelSummary1_TitleSection")
If @error Then Exit MsgBox(262144, "Exit due to error", "Error: " & @error & " Extended: " & @extended & @LF & 'ID not found: "ctl00_ctl00_ctl00_ctl00_ContentMain_ContentMain_ContentMain_ContentMain_TabContainer1_DetailsTab_DetailsController1_ctl00_ParcelSummary1_TitleSection"', 0)
MsgBox(262144, "href string",  $oid.href)

Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites
uncommon

#include <IE.au3>
#include <String.au3>
; sample URL $URL = "http://www.ocpafl.org/Searches/ParcelSearch.aspx/PID/312214078800170"
$URL = "http://www.ocpafl.org/Searches/ParcelSearch.aspx"
$oIE = _IECreate($URL)
MsgBox(262144, " ", "Please navigate to the desired page and then click OK", 0)
$oID = _IEGetObjById($oIE, "ctl00_ctl00_ctl00_ctl00_ContentMain_ContentMain_ContentMain_ContentMain_TabContainer1_DetailsTab_DetailsController1_ctl00_ParcelSummary1_TitleSection")
If @error Then Exit MsgBox(262144, "Exit due to error", "Error: " & @error & " Extended: " & @extended & @LF & 'ID not found: "ctl00_ctl00_ctl00_ctl00_ContentMain_ContentMain_ContentMain_ContentMain_TabContainer1_DetailsTab_DetailsController1_ctl00_ParcelSummary1_TitleSection"', 0)
MsgBox(262144, "href string", $oid.href)

Ah! Never thought about doing it that way, Thanks!

No problem can withstand the assault of sustained thinking.Voltaire

_Array2HTMLTable()_IEClassNameGetCollection()_IEquerySelectorAll()

Share this post


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
Sign in to follow this  

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I am having a hard time understanding why this is not working. I was hoping some one could help explain it to me. 
      $tags = $oIE.document.GetElementsByTagName("input") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "fTs-p3298-l0 wplEditControl" Then $target = $tag ExitLoop EndIF Next MsgBox(0,"",$target) If $target = "fTs-p3298-l0 wplEditControl" THEN MsgBox(0,"","itworked") I have tried 
       MsgBox(0,"",$target.Attribute)  MsgBox(0,"",$target.Value)  MsgBox(0,"",$target.InnerText) I would expect to see this in the msgbox
      fTs-p3298-l0 wplEditControl  
    • SkysLastChance
      By SkysLastChance
      I am trying to grab the id "in2xk_26" however it the characters before the underscore always change. (in the name too)
      Is there a way I can find a id or name by the last 3 charcters?
      Using something like "stringright?"
      So I would want to search for just "_26" in this case.
      This is assuming that there are no other _26
       

      #include <Excel.au3> #include <IE.au3> #include <GUIConstantsEx.au3> Global $iMousespeed = 25,$target = "",$TagName = "",$Value = "",$Atrribute = "" $oIE = _IEAttach("MEDITECH") $TagName = "input" $Value = "in2xk_26" $Attribute = "id" $tags = $oIE.document.GetElementsByTagName($TagName) ;TagName ------ MAKE SURE TO NAME THESE For $tag in $tags $class_value = $tag.GetAttribute($Attribute) ;Attribute ------ MAKE SURE TO NAME THESE If string($class_value) = $Value Then ;Value ------ MAKE SURE TO NAME THESE $target = $tag $iScreenX = _IEPropertyGet($target, "screenx") $iScreenY = _IEPropertyGet($target, "screeny") $iWidth = _IEPropertyGet($target, "width") $iHeight = _IEPropertyGet($target, "height") $oMouseCords = MouseMove($iScreenX + $iWidth / 2, $iScreenY + $iHeight / 2, $iMousespeed) MouseClick($MOUSE_CLICK_LEFT) ExitLoop EndIf Next  
       
    • SkysLastChance
      By SkysLastChance
      I was wondering how I read data inside of a iframe. I would like to be able to click something inside a iframe. However, I can't even find the tag. 
      The id and name change all the time so I can't use those. 
      The code highlighted in blue is what I am trying to click. (second picture)
      Here is what I have tried.
      $target = "" $tags = $oIE.document.GetElementsByTagName("div") For $tag in $tags $class_value = $tag.GetAttribute("class") If string($class_value) = "s_92 altstyle s_93 s_94" Then $target = $tag ConsoleWrite("Tag Found " & $target.outerText&@CRLF) ExitLoop EndIf Next  

       
       

    • SkysLastChance
      By SkysLastChance
       
      WinActivate("MEDITECH - Internet Explorer") Sleep (500) $oIE = _IEAttach("MEDITECH") $oDiv1 = _IEGetObjById($oIE, "sysmenu-searchbarbutton") _IEAction($oDiv1, "click") I am just trying to click the little magnifying glass, next to the gear button with no luck. I was hoping someone might have an idea why this is not working?
       

    • SkysLastChance
      By SkysLastChance
      I am trying to type a name in patient summary search box. How should I go about doing this. I am clearly not doing it right. (Attached Picture of HTML code.)
      This is what I have tried. I assume this is not working because it is not a form? 
      WinActivate("MEDITECH - Internet Explorer")       Sleep (500)    $oIE = _IEAttach("MEDITECH")    $oForm = _IEFormGetObjByName($oIE, "systemMenu")    $oText = _IEFormElementGetObjByName($oForm, "sysmenu-searchbarinput") _IEFormElementSetValue($oText, "Hey! This works!")
×