I was wondering if there was anything similar like Mechanize or BeautifulSoup for PHP?
SimpleTest 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
2009-08-12 02:15:44
You can use SimpleTest's browser without the rest of the framework. It's a self-contained subcomponent.
troelskn
2009-08-12 11:47:27
require_once(dirname(__FILE__) . '/simpletest.php'); and a dozen of other includes.
Alix Axel
2009-08-13 18:11:28
+2
A:
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
2009-08-12 04:20:21
+1 for the native suggestion, although doing XPath queries is several times more complex than doing the same thing in BeautifulSoup.
Alix Axel
2009-08-12 06:17:07
+1
A:
Don't know about BeautifulSoup, but there is phpquery which is similar to jquery
$doc = phpQuery::newDocument('<div/>');
$doc['div']->append('<ul></ul>');
$doc['div ul'] = '<li>1</li><li>2</li><li>3</li>';
$doc['ul > li:last'] = 'hello';
carlosz
2009-08-12 05:13:48
Thanks, SimpleTest seems a little superior however I'll give this one a look.
Alix Axel
2009-08-12 06:18:06