Sign in to follow this  
Followers 0
Klexen

Extract links by class instead of id?

3 posts in this topic

#1 ·  Posted (edited)

I know how to get links by id, using _IEGetObjById. Is it possible to get link by class?

If not, does anyone have an idea, on how I would get all the links from source code that start with <h3 class=r>

Below is a link that I would like to extract... I copied this from random google search source code viewing. I noticed all the links that I want start with <h3 class=r><a href=" etc..

I just want the href link.

Any ideas?

<h3 class=r><a href="http://www.webhostingtalk.com/profile/bob0rz" class=l onmousedown="return clk(this.href,'','','res','3','&amp;sig2=qn6aB3jIlKlDdPPFJ_b5YQ')">

Using

_StringBetween('<h3 class=r><a href="http://www.webhostingtalk.com/profile/bob0rz"', '"', '"')

That would give me what I want... But how do I pull all the links that start

<h3 class=r><a href="www.whatever.com" etc....>
from the source code? Edited by Klexen

Share this post


Link to post
Share on other sites



I know how to get links by id, using _IEGetObjById. Is it possible to get link by class?

If not, does anyone have an idea, on how I would get all the links from source code that start with <h3 class=r>

Below is a link that I would like to extract... I copied this from random google search source code viewing. I noticed all the links that I want start with <h3 class=r><a href=" etc..

I just want the href link.

Any ideas?

<h3 class=r><a href="http://www.webhostingtalk.com/profile/bob0rz" class=l onmousedown="return clk(this.href,'','','res','3','&amp;sig2=qn6aB3jIlKlDdPPFJ_b5YQ')">

Using

_StringBetween('<h3 class=r><a href="http://www.webhostingtalk.com/profile/bob0rz"', '"', '"')

That would give me what I want... But how do I pull all the links that start

<h3 class=r><a href="www.whatever.com" etc....>
from the source code?
That's a heading tag (level 3) and the link is a child element of the heading.

You can get a collection of all links with _IELinkGetCollection() and loop through the links testing $oLink.ParentNode.Class == "r".

Or, the other way around, get a collection of all h3 tags with _IETagNameGetCollection() and check each one for its first child link with $oH3.FirstChild

Neither tested, but I think it should help.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks man! I will definitely try this out and post feedback.

Edited by Klexen

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