FAQ
ok so im using HTML::TreeBuilder to pull some data off of a website and
parse it. If I'm understanding this right each tag of the tree is put
inside the tree as a hash reference with hash references inside of it
for each tag thats below it. Like:
<html><body><p> = $root_hash_ref->$body_hash_ref->$p_hash_ref

regardless if i understand the module or not, how do i dereference the
data i need? in other words, i need to be able to pull data out of the
hashes (i know where its kept) without iterating over it. i tried my
$piece = ${row}{3} where 3 would be they key number and that didnt work.
perlref was only so helpful and i only got some of the basics. any thoughts?

Search Discussions

  • Rob Dixon at Aug 29, 2007 at 7:18 pm

    Hunter Barrington wrote:
    ok so im using HTML::TreeBuilder to pull some data off of a website
    and parse it. If I'm understanding this right each tag of the tree is
    put inside the tree as a hash reference with hash references inside
    of it for each tag thats below it. Like: <html><body><p> =
    $root_hash_ref->$body_hash_ref->$p_hash_ref
    No, not at all. It's a linked structure of HTML::Element objects which
    can be navigated by using object method calls. Take a look at

    perldoc HTML::Element

    for an idea of the sort of things you can do.
    regardless if i understand the module or not, how do i dereference
    the data i need? in other words, i need to be able to pull data out
    of the hashes (i know where its kept) without iterating over it. i
    tried my $piece = ${row}{3} where 3 would be they key number and that
    didnt work. perlref was only so helpful and i only got some of the
    basics. any thoughts?
    You can use the address() method if the HTML element you need is always
    in the same place in the HTML document, but this is a little risky if
    the document can change at all. Or you can find it by context using
    look_down(). If you give us an example of what it is you're trying to
    extract then we can help you better,

    Rob
  • Hunter Barrington at Aug 29, 2007 at 7:26 pm
    thnx for the reply.

    code @ http://barringtonweb.com/code.txt

    trying to pull data out of the td elements without iterating over them

    will look at html::element perldoc

    thanks a lot i think thats what i was missing,
    -Hunter

    Rob Dixon wrote:
    Hunter Barrington wrote:
    ok so im using HTML::TreeBuilder to pull some data off of a website
    and parse it. If I'm understanding this right each tag of the tree is
    put inside the tree as a hash reference with hash references inside
    of it for each tag thats below it. Like: <html><body><p> =
    $root_hash_ref->$body_hash_ref->$p_hash_ref
    No, not at all. It's a linked structure of HTML::Element objects which
    can be navigated by using object method calls. Take a look at

    perldoc HTML::Element

    for an idea of the sort of things you can do.
    regardless if i understand the module or not, how do i dereference
    the data i need? in other words, i need to be able to pull data out
    of the hashes (i know where its kept) without iterating over it. i
    tried my $piece = ${row}{3} where 3 would be they key number and that
    didnt work. perlref was only so helpful and i only got some of the
    basics. any thoughts?
    You can use the address() method if the HTML element you need is always
    in the same place in the HTML document, but this is a little risky if
    the document can change at all. Or you can find it by context using
    look_down(). If you give us an example of what it is you're trying to
    extract then we can help you better,

    Rob

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedAug 29, '07 at 6:57p
activeAug 29, '07 at 7:26p
posts3
users2
websiteperl.org

2 users in discussion

Hunter Barrington: 2 posts Rob Dixon: 1 post

People

Translate

site design / logo © 2021 Grokbase