HTML parsers
Options for parsing HTML in PHP, roughly from worst to best:
- Regular expressions — technically possible, but fragile and hard to maintain for real HTML.
- open_in_new phpQuery — jQuery-style API, but no longer actively maintained.
- PHP Simple HTML DOM Parser — jQuery-like selectors, also fairly old.
- open_in_new DiDOM — the most actively maintained of the three, and the recommended default choice.
Related: proxies , CAPTCHA solving .
PHP Simple HTML DOM Parser
Using
Selecting an element:
$page_content->find("#product_enabled", 0)->plaintext;
Andrew Dorokhov