Sign in to follow this  
Followers 0
Kidney

Easier way to find links on a webpage?

7 posts in this topic

So i have a website that i use for work that has a bunch of call reports that i fill out every day i work.

these call reports ask a bunch of questions that are easy but it gets annoying after about 100 of them. So im trying to make a script that will fill in the easy questions like: Time in, Time out, time spent at work in minutes, inventory level of x y z items, morning shift or night shift, etc

 

I have gotten the script to log in for me and navigate to the point where there are a list of call reports but it seems that the page has multiple frames and multiple tables but i cant figure out how to get the links for all of the call reports.

and to make matters worse, the site only works in IE. So i have to use the IE functions.

 

So i guess my question is, is there some type of tool that i can use that can help me access links that are berried in tables and iframes?? i can post the html if that helps anyone. but its about 1700 lines of code.

 

Thx :)

Share this post


Link to post
Share on other sites



Did you try _IELinkGetCollection and _IEFrameGetCollection ?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If I were you, I'd open the page in developer tool (F12) and check out the id or name of frame that contain links. Then (assuming the frame id or name is "contentFrame"):

$oIE = _IECreate("address")
$frame = $oIE.document.getElementById("contentFrame")
$links = $frame.contentWindow.document.getElementsByTagName("a")
For $link In $links
    ConsoleWrite($link.src & @CRLF)
Next
Edited by karlkar

Share this post


Link to post
Share on other sites

Did you try _IELinkGetCollection and _IEFrameGetCollection ?

Ya i did =/

Use  developer tool (F12) or freeware 'Debugbar'

 

Awesome! This is what i needed!

 

 

Now, im not asking for anyone to code this i just want to make sure i know what step r needed to actually click on one of these links.

post-65938-0-64733000-1385933488_thumb.j

Hopefully you can see the code a little.

So if i wanted to click on the link that is highlighted, i would need to:

1) Get the handle of the body which is id= "b"

2) Get the Handle of div id = "d"

3) Get the handle of the iframe name = "main"

4) Get the handle of frame name = "fra_Main"

5) Get the handle of form name = "frmStoreList"

6) Get the handle of the First table

7) Get the handle of the second table which is inside the first table

8) Get the table data

9) click on the link

does this seem correct?? Did i miss a step or do i have too many steps? Just curious and then ill take a stab at it.

 

Thx guys!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Just get the frame (you can skip first three points). Then using my code above get all tables from the frame and iterate over them as long as you will find the one matching borderColor attribute (as I see that they are different for the first and second table). Of course you can get all tables and then take the second element, but this is not as change-proof. I mean there may appear some dynamic content that will change this tables to be for example second and third.

Or you can use exactly the same code as I posted before with checking if attributes are meeting your requirements.

no matter what you do - you have to get the frame first.

Edited by karlkar

Share this post


Link to post
Share on other sites

i tried your code above and im getting errors. am i supposed to change the "a" in the getElementsByTagName?

i tried your code with "main" and "fra_Main" and neither of them returned anything in the console.

 

ill post the error codes when i get home. 

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