Jump to content

Links outside Tables


fhanna
 Share

Recommended Posts

I have no problem retrieving links from a web page but only want the ones within a Table. In using the _IELinkGetCollection I retrieve them all. Could someone assist by an additional statement within this command or is their a way via the _IETagnameGetCollection or similar.

Thanks you.

Link to comment
Share on other sites

fhanna,

The following example reads a downloaded HTML source file and outputs links within tables.

Note - I'm just learning how to work with HTML objects so I'm sure that there are other/better way to do this, but this works for me.

#include <IE.au3>
#include <array.au3>

_lnks(fileread('my.file'))

ConsoleWrite(@error & @LF)

Func _lnks($html_code)

    Local $o_htmlfile = ObjCreate('HTMLFILE')

    If Not IsObj($o_htmlfile) Then Return SetError(-1, 0, '')

    $o_htmlfile.open()
    $o_htmlfile.write($html_code)
    $o_htmlfile.close()

    Local $otbls = _IETagnameGetCollection($o_htmlfile, 'TABLE')

    if not isobj($otbls) then return seterror(-2)

    for $otbl in $otbls
        local $olnks = _ietagnamegetcollection($otbl, 'A')
        if not isobj($olnks) then return seterror(-3)
        ConsoleWrite('Links for table = ' & $otbl.id & ' ' & $otbl.title & ' ' & $otbl.summary & @LF)
        for $olnk in $olnks
            ConsoleWrite(@tab & $olnk.href & @LF)
        next
    next

EndFunc

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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...