Parser

Discussion in 'Programming' started by dukeofism, Aug 22, 2009.

  1. #1
    I was reading somewhere on a blog and the blogger had written about a writing a "parser". (link: http://silentmac.com/) I'm curious. What is a parser (in the way the blogger is referring to one)?
     
    dukeofism, Aug 22, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    A parser is a script written to extract information from an unstructured page, typically a HTML page. They simply use patterns to find the start and end of each bit of information they need.. In your case someone did just that to find out their total apple app store earnings.
     
    premiumscripts, Aug 22, 2009 IP
  3. dukeofism

    dukeofism Peon

    Messages:
    739
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the response. Does that mean a parser could be used to extract information displayed in a <table> by looking for the <table> tags?
     
    dukeofism, Aug 22, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yes, if you know exactly in which fields. Though there are two kinds of parsers for HTML, the regular old parser simply looks at patterns: <tr>.*</tr> to match everything in a row.. The new one uses the DOM (the browser object model) so that you can navigate and parse exactly as you would in HTML.
     
    premiumscripts, Aug 22, 2009 IP
  5. dukeofism

    dukeofism Peon

    Messages:
    739
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for your help!
     
    dukeofism, Aug 22, 2009 IP