Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: HTML::Parser guidance

by smls (Friar)
on May 28, 2013 at 15:39 UTC ( [id://1035637]=note: print w/replies, xml ) Need Help??


in reply to HTML::Parser guidance

Well the first thing you need to do when it comes to parsing data records from HTML documents, is to look at the markup structure of the document and determine the simplest "search rule" that matches all data records (without matching any false positives).

If I understand your post correctly, each record in your case will be of the form <div class="message1">...</div>. But that's not enough information to determine the "search rule" for matching all of them, you need to look at what exactly changes from record to record, and at the page structure they're embedded in.
Here are some examples of what the "search rule" could be, depending on the exact document structure at hand (sorted from simpler to more complex):

  • "All <div> elements anywhere in the document"
  • "All <div> elements that are direct children of <body>"
  • "All <div> elements that are direct children of a container element that has a unique id"
  • "All <div> elements that have the attribute class="message1""
  • "All <div> elements that have the attribute class="messageX", with X being a number"
  • "All <div> elements that have a <span class="id"> child element"
  • ...
Once you have determined the simplest rule for matching records (and no false positives!) for your particular use-case, you can then start thinking about how to implement the parsing. Report back once you are at that stage and need more help with that.

PS: As for formatting questions on PerlMonks, it's best to put code (including HTML markup) in <code>...</code> tags - among other benefits you can then keep the angled brackets in the code, they will show up verbatim.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1035637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-25 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found