Sign in to follow this  
Followers 0
uncommon

IE find a dynmic link

7 posts in this topic

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



#2 ·  Posted (edited)

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

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

@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

#5 ·  Posted (edited)

#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

#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  
Followers 0

  • Similar Content

    • milos83
      By milos83
      I have one script that creates _IECreateEmbedded and another script that does _IEAttach.
      I do this because when autoit is doing something, the Embedded IE starts stalling (eg jquery progress animation)
      But there is a new problem.
      When IE is having its own process (like in the example above) any _IE command is slow (in the script that Attaches).
      Here is a comparison of when its in separate and when its in same process:
      Separate process _IETagNameGetCollection : 5000ms
      Separate process _IEAction: 850ms
      Same process _IETagNameGetCollection : 1ms
      Same proccess _IEAction: 135ms
       
      If I try to attach to an embedded IE that is done in c#, I get lightning fast results.
      As you can see, _IE functions work very slow when the embedded IE we are attaching to is made in Autoit.
       
      I did a test and if I empty the WHILE loop in IE process I get these results(but the cpu is at 30% as expected):
      Separate process _IETagNameGetCollection : 33ms
      Separate process _IEAction: 13ms
       
      It slows down if you put anything (like GUIGetMsg) in the WHILE loop.
       
      How do I fix this?
       
      Create IE:
      #include <GUIConstantsEx.au3> #include <IE.au3> #include <WindowsConstants.au3> Local $oIE = _IECreateEmbedded() GUICreate("My Embedded Web control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN) GUICtrlCreateObj($oIE, 10, 40, 600, 360) GUISetState(@SW_SHOW) ;Show GUI _IENavigate($oIE, "http://www.autoitscript.com") $timer = TimerInit() $oLink = _IETagNameGetCollection($oIE, "a", 3) ;takes 1ms ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _IEAction($oLink, "click") ;takes 135ms ConsoleWrite(TimerDiff($timer) & @CRLF) While 1 Local $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd  
      Attach to IE:
      #include <IE.au3> Local $oIE = _IEAttach("My Embedded Web control Test", "embedded") $timer = TimerInit() $oLink = _IETagNameGetCollection($oIE, "a", 3) ; 5000ms ConsoleWrite(TimerDiff($timer) & @CRLF) $timer = TimerInit() _IEAction($oLink, "click") ; 850ms ConsoleWrite(TimerDiff($timer) & @CRLF)  
       
      attach.au3
      create.au3
    • nacerbaaziz
      By nacerbaaziz
      hello
      please i need to link a progress bar with a time can you help me?
      e.g
      i want to set a progress bar for 10 sec
      am waiting for your answers
      thank you.
    • nassausky
      By nassausky
      Hi all,
       
      Anyone have any idea how to close all open tabs except a specific one I manually open.  Assuming I don't know what is open in all the tabs except just the one I want to keep open.
       
      I didn't want to use sendkeys and I was trying to use the following code to list the title (or url) of the 3 open tabs and  after I got that part working I would just close the other 2. This sample only displays the title of the first open tab
      #include <IE.au3> Const $ie_new_in_tab = 0x0800 $oIE = _IECreate("https://www.autoitscript.com") __IENavigate($oIE, "https://www.autoitscript.com/forum/", 1, $ie_new_in_tab) ;(obj,url,wait,param) __IENavigate($oIE, "https://www.google.com/", 1, $ie_new_in_tab) ;(obj,url,wait,param) Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIE While 1     $oIE = _IEAttach("", "instance", $i)     If @error = $_IEStatus_NoMatch Then ExitLoop     ConsoleWrite(_IEPropertyGet($oIE, "title") & @CRLF)     ReDim $aIE[$i + 1]     $aIE[$i] = $oIE ;each item holds object     $aIE[0] = $i ;first item holds count     $i += 1 WEnd MsgBox($MB_SYSTEMMODAL, "Browsers Found", "Number of browser instances in the array: " & $aIE[0]) ; This doesn't return the list of tabs in the console just the first tab  
      Thanks for any and all help
    • toto22
      By toto22
      I'm trying to click on Java Dropbox using IE. However, I'm running into problems. There is a Dropbox "Please Select" with two options "Buy" and "Sell".
      I'm able to click on a drop box (please see code below) but i'm unable to select "Buy" or "Sell"".
      Local $sMyString = "Please Select" ;############ ENTER ############# Local $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks Local $sLinkText = _IEPropertyGet($oLink, "innerText") If StringInStr($sLinkText, $sMyString) Then _IEAction($oLink, "click") ExitLoop EndIf Next  
      Please help
       
         
    • Gowrisankar
      By Gowrisankar
      Hello everyone,
      I'm working on a task where, a PDF file is opened (in IE browser) when I click a link in a website.
      I have to read the first page of the PDF to find particular strings. Can you please share some ideas?