in reply to look_up() in HTML::Element Not Traversing As Expected
If we clean up that HTML so that most of the cruft is removed we get:
<tr valign="top"> <td> <table class="imagetable"> <tr> <td> <a href="URL1"><img src="IMG1"></a> <a href="URL2">JASON FEDDY</a> </td> </tr> </table> </td> <td>Replied </td> <td><a class="mailtext" href="URL3">Hello mate</a></td> </tr>
Now, look at the HTML and notice that you are finding URL3, but want to navigate back to URL1. look_up can't do that. URL1 is not above URL3 in the element tree, it's in a completely different branch!
You need to sit back and think about your rules for finding URL1 given URL3. There are a bunch of ways it could be done, but it depends a great deal on how the structure of the HTML can change. I don't think it is even worth giving a solution in this particular case because you really need to accommodate possible changes in the HTML and I have no idea what those may be. In the simplest case you can just navigate up using parent, then work your way back down indexing into the contents array. But that is mighty fragile!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: look_up() in HTML::Element Not Traversing As Expected
by initself (Monk) on Apr 29, 2006 at 03:54 UTC | |
by GrandFather (Saint) on Apr 29, 2006 at 04:07 UTC |