Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP CSS Selector Library? [closed]

Is there a PHP class/library that would allow me to query an XHTML document with CSS selectors? I need to scrape some pages for data that is very easily accessible if I could somehow use CSS selectors (jQuery has spoiled me!). Any ideas?

like image 303
Wilco Avatar asked Nov 04 '08 02:11

Wilco


4 Answers

After Googling further (initial results weren't very helpful), it seems there is actually a Zend Framework library for this, along with some others:

  • DOM-Query
  • phpQuery
  • pQuery
  • QueryPath
  • Simple HTML DOM Parser
  • Ultimate Web Scraper Toolkit
  • Zend-Dom
like image 76
Wilco Avatar answered Oct 18 '22 20:10

Wilco


XPath is a fairly standard way to access XML (and XHTML) nodes, and provides much more precision than CSS.

like image 40
nickf Avatar answered Oct 18 '22 21:10

nickf


Another one:
http://querypath.org/

like image 6
mario Avatar answered Oct 18 '22 21:10

mario


A great one is a component of symfony 2, CssSelector\Parser­Introduction. It converts CSS selectors into XPath expressions. Take a look =)

Source code

like image 6
Clement Herreman Avatar answered Oct 18 '22 21:10

Clement Herreman