title: XPath, Simple HTML DOM or REGEX when scraping web pages
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php">How to parse and process HTML with PHP?</a>  </p>
  </blockquote>
  
  
  
  <p>What is in your opinion/experience the best approach when scraping web pages for specific info?</p>
  
  <p>I am building a system (PHP/JS/MySQL) that should automatically scrap specific fields of info from specified web pages. This system needs a functionality that, after you (semi)manually scrape first page on that website, the logic goes to the db and it is used to scrape any other page in that format on the website.</p>
  
  <p>I am able to quickly find and save the HTML DOM (tag name + class + id) and the XPath and add some filter rules (like clean HTML, break at first tag, remove specific words...)</p>
  
  <p>My question (again :)) is: What is best method to use in this automation to be able to scrape the pages properly? </p>
  
  <p>Ex: </p>
  
  <blockquote>
    <p>Simple HTML DOM: <a href="http://simplehtmldom.sourceforge.net/" rel="nofollow noreferrer">http://simplehtmldom.sourceforge.net/</a> <br/>
    XPath: <a href="http://docs.jquery.com/DOM/Traversing/Selectors#XPath_Selectors" rel="nofollow noreferrer">http://docs.jquery.com/DOM/Traversing/Selectors#XPath_Selectors</a><br/>
    regex....</p>
  </blockquote>
  
  <p>Any other suggestions are welcome</p>
  
  <p>UPDATE: I have used XPath, Simple HTML DOM and regex. 
  In order to automate and to make an easy configurator (an interface used to configure the scraping rules) when scraping a particular website, Simple HTML DOM is the best. Unfortunately XPath is far from useful in 90% of the cases, Simple HMTL DOM is working for at least 50% of the cases with great successes)</p>
  
  <p>I have also added recently a regex component where I add the rules manually written and they are working very very well (at least 80% if the cases). Is just a lot of manual work</p>