问题
I was wondering if there was anything similar like Mechanize or BeautifulSoup for PHP?
回答1:
SimpleTest provides you with similar functionality:
http://www.simpletest.org/en/browser_documentation.html
回答2:
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.
来源:https://stackoverflow.com/questions/1263800/mechanize-and-beautifulsoup-for-php