php|architect's Guide to Web Scraping with PHP - Wind Business ...
php|architect's Guide to Web Scraping with PHP - Wind Business ...
php|architect's Guide to Web Scraping with PHP - Wind Business ...
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
CSS Selec<strong>to</strong>r Libraries ” 133<br />
• li:first selects only the first li node found in the document.<br />
• li:last likewise selects the last li node found in the document.<br />
• li:even selects all evenly positioned nodes in the document beginning from 0.<br />
• li:odd likewise selects all oddly positioned nodes in the document, also beginning<br />
from 0.<br />
• li:eq(0) selects the li node <strong>with</strong> a position of 0 <strong>with</strong>in the set of li nodes (i.e.<br />
the first one) in the document.<br />
• li:gt(0) selects all li nodes <strong>with</strong> a position greater than 0 <strong>with</strong>in the set of li<br />
nodes (i.e. all but the first one) in the document.<br />
• li:lt(1) selects all li nodes <strong>with</strong> a position less than 1 <strong>with</strong>in the set of li<br />
nodes (i.e. the first one) in the document.<br />
• :header matches all header nodes. (i.e. h1, h2, etc.)<br />
• :not(:first) negates the :first selec<strong>to</strong>r and thus selects all li nodes except<br />
the first one in the document.<br />
Selec<strong>to</strong>r CSS XPath<br />
first node li:first //li[1]<br />
last node li:last //li[last()]<br />
even nodes li:even //li[position() mod 2 =<br />
odd nodes li:odd //li[position() mod 2 =<br />
specific node li:eq(0) //li[1]<br />
all nodes after li:gt(0) //li[position() > 1]<br />
all nodes before li:lt(1) //li[position() < 2]<br />
header nodes :header //h1|//h2|//h3|//h4|//h5|<br />
0]<br />
1]<br />
all nodes not<br />
matching an expression<br />
//h6<br />
:not(:first) //*[not(position() =<br />
1)]