I was wondering if there was anything similar like Mechanize or BeautifulSoup for PHP?
Asked
Active
Viewed 1.8k times
2 Answers
9
I don't know how powerful BeautifulSoup is, so maybe this won't be as great ; but you could try using DOMDocument::loadHTML
:
The function parses the HTML contained in the string source . Unlike loading XML, HTML does not have to be well-formed to load.
After using this, you should be able to access the HTML document using DOM methods -- including XPath queries.

Pascal MARTIN
- 395,085
- 80
- 655
- 663
-
2+1 for the native suggestion, although doing XPath queries is several times more complex than doing the same thing in BeautifulSoup. – Alix Axel Aug 12 '09 at 06:17
8
SimpleTest provides you with similar functionality:

Aziz
- 20,065
- 8
- 63
- 69

Jonathan Holloway
- 62,090
- 32
- 125
- 150
-
1SimpleTest Browser class indeed does seem to do the job right however I was looking for something lighter, perhaps some library not oriented for Unit Testing? – Alix Axel Aug 12 '09 at 02:15
-
1You can use SimpleTest's browser without the rest of the framework. It's a self-contained subcomponent. – troelskn Aug 12 '09 at 11:47
-
1require_once(dirname(__FILE__) . '/simpletest.php'); and a dozen of other includes. – Alix Axel Aug 13 '09 at 18:11
-
1
-
You can try this php package https://github.com/amsify42/php-domfinder – Mohammed Samiullah Sep 02 '19 at 09:51