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

    • Seminko
      By Seminko
      Hey,
      i would like to set a value into an INPUT field.
      Checked the _IEFormElementSetValue function but that does require _IEFormGetObjByName and this is where the problem comes in. The input field I want to write to is not a part of a form tag. It is part of a table.
      <input type="text" class="w2" id="nabidka_vozidel_formular_tach_od" name="nabidka_vozidel_formular_tach_od" onchange="GLOBAL.pocetInzerceNZ(&quot;nabidka_vozidel_formular&quot;,&quot;tach_od&quot;,&quot;&quot;);" autocomplete="off"> I tried this but that didn't work:
      $oDownloadSamples = _IEGetObjById($oIE, "nabidka_vozidel_formular_tach_od") _IEFormElementSetValue($oDownloadSamples, "123") If you want to try the site I'm working with is https://www.tipcars.cz/. There is a menu on the top left hand side and if you click the "vyhledat" button the input fields will show up.
      Thanks
    • Seminko
      By Seminko
      I am now able to populate the dropdown menus at https://www.tipcars.com/.
      The dropdowns are dynamic and do not have a Text value, only ids.
      Is there a way to get all the available options from a dropdown?
      $url = "https://www.tipcars.com/" $oIE = _IECreate($url) _IELoadWait($oIE) $oDownloadSamples = _IEGetObjById($oIE, "homepage_vyhl_frm_vozidlo") _IEFormElementOptionSelect($oDownloadSamples, "C") Above code, populates ID 'C' into the 'druh' dropdown, which results in selecting 'užitkové'. 
      Is there a way so I can grab all of the options from the dropdown menu? I could easily grab all the IDs but I am afraid they will change in the future so I would much rather match the text titles and assign the option IDs grabbed from site.
      This is what the options are according to Chrome:
      <select class="w1"id="homepage_vyhl_frm_vozidlo"name="homepage_vyhl_frm_vozidlo"onchange="try{NABIDKA_VOZIDEL_FORMULAR.naplnSelectZnacka('homepage_vyhl_frm');GLOBAL.pocetInzerceHZ('homepage_vyhl_frm','vozidlo');}catch(ex){odeslatJsChybu('formHOMEPAGE onChange 1: ' + ex.message, 'formHomePage onChange 1', -1);}"> <option value="A" style="color: black;">osobní a terénní (56 334)</option> <option value="C" style="color: black;">užitkové (4 333)</option> <option value="D" style="color: black;">nákladní (3 742)</option> <option value="E" style="color: black;">autobusy (56)</option> <option value="F" style="color: black;">obytné (373)</option> <option value="G" style="color: black;">přívěsy (1 179)</option> <option value="J" style="color: black;">motorky (780)</option> <option value="S" style="color: black;">pracovní stroje (605)</option> <option value="L" style="color: black;">ostatní (235)</option></select> Also, this cannot be grabbed by _INetGetSource.
      Thanks
    • Spask
      By Spask
      Hi, I'm trying to find a text value inside of a html.
      This is what the line looks like normally:
      <p id="line1" class> <span class="bot">TEXT HERE</span> </p> The text then changes to a non breaking space:
      <p id="line1" class> <span class="bot">&nbsp;</span> </p> And then it changes back to normal text but it's different every time.
      Can I code this so that it grabs the text every time it changes and has a variable that represents it?
      I currently have this inside of my loop:
      $span = .document.getElementsByTagName("span") For $text In $span If $text.value = "&nbsp;" Then Sleep(50) MsgBox(0,0,0) ;messagebox to test if it can be found, but I don't know how to grab the text EndIf Next The problem is that there are many other lines in the html that have the same span but are called "line3", "line5", etc and the one I need is from "line1".
      I will appreciate if anyone can help with this!
    • electrons
      By electrons
      hi  , hope  you all doing well 
       cant find any elements on the page ?  and the right click mouse dont work too?
      iam trying with more than method , i need help please!!
       

    • ur
      By ur
      I have kept below line to wait for IE to load the site completely and continue.
      _IELoadWait($oIE)
       
      But, the code is continuing without waiting for it and I my execution is failing as the elements are not loaded completely.

       
      Any suggestions for alternate code to wait for the browser to load completely?