Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

php|architect:
Introducing four new PHP 5.3 components and Goutte, a simple web scraper
Apr 23, 2010 @ 19:50:18

On the php|architect blog today there's a new post from Ryan Weaver about some of the new components that've been added to the Symfony framework - BrowserKit, CssSelector, DomCrawler, Process and a project that uses them all, Goutte.

To support symfony 2’s development, Fabien Potencier – the lead developer of the symfony framework – has released four new PHP 5.3 based components. [...] Though these components will be used by Symfony 2, they’re built to be standalone components that can be easily used in any PHP 5.3 project.

The post lists each of them out including features and some sample code as well as a brief look (mostly code) at using to locate specific contents in a page.

tagged: browserkit cssselector domcrawler process symfony component goutte

Link:

Fabien Potencier's Blog:
Parsing XML documents with CSS selectors
Apr 02, 2010 @ 14:41:27

In a new post Fabien Potencier talks about how he took the Python lxml.cssselect component from Python, ported it over to PHP and made a library that allows you to parse XML with the handy CSS selectors rather than using XPath.

Odds are you [also] need to parse some from time to time: because you consume a web service and want to extract some information, or because you want to gather data from scraped web pages, or just because you want to write functional tests for a website.

The CssSelector tool allows you to convert a CSS selector into an XPath that can, in turn, be pushed into the XPath function of the PHP DOM XML functionality. He gives a few examples of using it for a simple "find" and for something more complex involving a SimpleXML object too.

The library can be downloaded from github here.

tagged: xml parse css selector cssselector tutorial

Link:


Trending Topics: