Jump to content

[Help] Filter link when use _IELinkGetCollection


Recommended Posts

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 ^_^

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...