Jump to content
Sign in to follow this  
anhchangtk

[Help] Filter link when use _IELinkGetCollection

Recommended Posts

anhchangtk

Now, I do making 1 tool search from google, I had use _IELinkGetCollection to get all results find out. And don't want collect links "http://google.com" And how do Filter 1 or manay link don't need

EX: I don't need collection 4 link:

http://www.google.com/intl/vi/help.html

http://www.google.com/intl/vi/ads/

http://www.google.com/services/

http://www.google.com/intl/vi/about.html

And my code:

#include <IE.au3>
$oIE = _IECreate("http://www.google.com/search?hl=en&q=Cry+On+My+Shoulder&btnG=Google+Search&aq=f&oq=")
$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
For $oLink In $oLinks
   Msgbox(0,"Link Collection",$oLink.href)
Next

Thanks you has view my post ^_^

Share this post


Link to post
Share on other sites
DaleHohm

One thing you can do is scope the search within the page to the area that contains the results. These are in a DIV section with an id of "res" (easily learned using DebugBar). You can then get all of the "a" tags within that section (_IELinkGetCollection always works on the entire document. E.g.:

#include <IE.au3>
$oIE = _IECreate("http://www.google.com/search?hl=en&q=Cry+On+My+Shoulder&btnG=Google+Search&aq=f&oq=")
$oDiv = _IEGetObjById($oIE, "res")
$oLinks = _IETagnameGetCollection($oDiv, "a")

You'll find these links to be much more what you want. Beyond that you'll need to loop through the links and examine each one.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
anhchangtk

Thanks you ^_^

But i don't understand:

Why use "res" and "a" in _IEGetObjById and _IETagnameGetCollection mean 2 this word?

Share this post


Link to post
Share on other sites
DaleHohm

I don't understand what you don't understand.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites
anhchangtk

Why you use the below code:

$oDiv = _IEGetObjById($oIE, "res")

$oLinks = _IETagnameGetCollection($oDiv, "a")

I don't understand:

Why in "res" and "a"

What it mean ???

Can me replace other words?

Share this post


Link to post
Share on other sites
Authenticity

res is the ID of the div element in that page which must be unique. By getting an object reference to it and using it in the _IETagnameGetCollection() you're limiting the scope of the function to search for <a> tags just within this element and not the entire page if you called it like this, for example:

$oLinks = _IETagnameGetCollection($oIE, 'a')

a if for <a> tags.

Share this post


Link to post
Share on other sites
anhchangtk

Thanks you very much ^_^

I has understand ;)

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.