Sign in to follow this  
Followers 0
WLGades

Detect links on an HTML page?

16 posts in this topic

Hello, I've searched the forums but nothing popped up. I may have missed it, though, so if this is a repeat I apologize (and please, point me to where I can find it).

How can I click a specific link on the page, if I don't know where it necessarily shows up? Is it possible go through all links until a certain link is found, then hit {ENTER} or some such?

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hm, but what if the link text isn't unique, while the link is? Say there are a lot of links that say "link" but they go to different pages. Is it still possible to find where they point to?

edit: Actually, I can't even seem to get that to work. :-) I did a search for the name of the link, and it finds it correctly, but when I hit tab it starts at the beginning. Is it not working because of frames?

edit2: Another way I just thought of is to tab through all the links, then do copy shortcut and search the returned string.

Edited by WLGades

Share this post


Link to post
Share on other sites

edit: Actually, I can't even seem to get that to work. :-) I did a search for the name of the link, and it finds it correctly, but when I hit tab it starts at the beginning. Is it not working because of frames?

I think you're right about the frames: for me it works fine on MSIE 5.5 & 6 .. until I try a frames site: then the found text stays highlighted, and focus seems to shift to the entire frame itself - and a subsequent tab (sometimes!) takes me to the first link in that frame. :D

I think your suggestion to walk the links and inspect the shortcuts is the safest. Since it sounds like such a pain, it might make a good UDF to share on Scripts and Scraps :huh2:

Share this post


Link to post
Share on other sites

I think you're right about the frames: for me it works fine on MSIE 5.5 & 6 .. until I try a frames site: then the found text stays highlighted, and focus seems to shift to the entire frame itself - and a subsequent tab (sometimes!) takes me to the first link in that frame.  :D

I think your suggestion to walk the links and inspect the shortcuts is the safest. Since it sounds like such a pain, it might make a good UDF to share on Scripts and Scraps  :huh2:

How you gonna read the string that has been tabbed to then?

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

WLGades was going to do a "copy shortcut" and inspect that.

Share this post


Link to post
Share on other sites

This is what I came up with a few days ago, and it seems to work. The StatusbarGetText call of course relies on the window, etc. I don't think there's a way to find the text without knowing it beforehand.

Func FindLink($link)
    $i = 0
    While $i < 500
  $x = StatusbarGetText("Microsoft Internet Explorer")
  if ($x = $link) Then Return(1)
  Send("{TAB}")
  $i = $i + 1
    WEnd
    Return(0)
EndFunc

Share this post


Link to post
Share on other sites

This is what I came up with a few days ago, and it seems to work.  The StatusbarGetText call of course relies on the window, etc.  I don't think there's a way to find the text without knowing it beforehand.

Func FindLink($link)
    $i = 0
    While $i < 500
  $x = StatusbarGetText("Microsoft Internet Explorer")
  if ($x = $link) Then Return(1)
  Send("{TAB}")
  $i = $i + 1
    WEnd
    Return(0)
EndFunc
So you're reading the status bar to see what the link is? Clever hope there's no mouse over status bar functions to mess that up

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

Yeah, and that it actually displays the link instead of some weird text. :-) No problems yet, though.

Share this post


Link to post
Share on other sites

This is what I came up with a few days ago, and it seems to work.  The StatusbarGetText call of course relies on the window, etc.  I don't think there's a way to find the text without knowing it beforehand.

Func FindLink($link)
    $i = 0
    While $i < 500
  $x = StatusbarGetText("Microsoft Internet Explorer")
  if ($x = $link) Then Return(1)
  Send("{TAB}")
  $i = $i + 1
    WEnd
    Return(0)
EndFunc
I just tried the status bar thing to a junkemail responder I wrote for hotmail and it works great thanks guys! I added a mousemove to 0,0 to make sure the mouse wouldn't cause any status bar text

Thanks

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

You might want to try this too ..

Send("{TAB}")              ;Next link
        Send("{APPSKEY}t{ENTER}")  ;Copy destination to clipboard

.. it gets the link destination first-hand, from the horse's mouth :D

Edited by trids

Share this post


Link to post
Share on other sites

This is probably a better option, if you're free to scan a download separately from the browser.

I prefer this way, cos it's independent of the browser and its (MSIE's) truculent ways :D

HTH

Share this post


Link to post
Share on other sites

Nice implementation. Not something I'd use because I think it's more than I need, but well done. I thought about doing the Copy Shortcut, too, but scanning links is faster, and if it works, then I'd rather do it that way. :-)

Share this post


Link to post
Share on other sites

I'm just getting into this with a goal of automating my standard Web info accesses.

The above opinion was that there was no way to get the name of the link off the web page. Seems to me though that they are in the page source so..

while you gather the links why not gather the web text at the same time.

eg: in this forum I look at the source and following the link for each note author is the text name. eg: WLGades..trids but..

since I don't know much about html maybe this is not always the case.

Comments?

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Some time ago I made my own version of "Link Lister".

You say you want the link names too?

Allright then.

I'll clean my script up and add it.

Edit:

Here it is: http://www.autoitscript.com/fileman/users/public/SlimShady/ExtractURLs.au3

I used my UDFs in this script. So instead of AutoIt including them, I did it manually.

When you run it, it will ask you for the URL of a webpage.

When it is done, it creates a textfile and shows it.

It will delete the file one second after notepad opens the file.

Just above the part where notepad is run, you can use the array $Links.

$Links[n][d]

n stands for the link number or link name number.

d can be 0 or 1.

0 is the dimension with links.

1 is the dimension with the link names.

Have fun.

Edited by SlimShady

Share this post


Link to post
Share on other sites

Thanks for the script. I'm trying to do this without getting the source, but I'm sure other people will find that it's helpful.

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