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.
136 ” CSS Selec<strong>to</strong>r Libraries<br />
Child F i l t e r s<br />
Child filters are fairly similar <strong>to</strong> the basic filters reviewed earlier, except applied <strong>to</strong><br />
child nodes.<br />
• ul:nth-child(2) selects the second child element <strong>with</strong>in each ul node. The<br />
parameter passed <strong>to</strong> the filter can also be even or odd (which are figured relative<br />
<strong>to</strong> child position <strong>with</strong>in the parent element) or can use expressions involving<br />
a variable n (such as 3n for every third child).<br />
• li:first-child selects all li nodes that are the first child of their parent node.<br />
• li:last-child likewise selects all li nodes that are the last child of their parent<br />
node.<br />
• li:only-child selects all li nodes that are the only child of their parent node.<br />
Selec<strong>to</strong>r CSS XPath<br />
nth child nodes ul:nth-child(2) //ul/*[position() = 2]<br />
first child nodes li:first-child //*/*[name() = “li” and<br />
position() = 1]<br />
last child nodes li:last-child //*/*[name() = “li” and<br />
position() = last()]<br />
only child nodes li:only-child //*/*[name() = “li” and count()<br />
= 1]<br />
F o r m F i l t e r s<br />
F o r m filters are just a more convenient shorthand for other expressions.<br />
• :input matches all input, textarea, select, and but<strong>to</strong>n elements.<br />
• :text, :hidden, :password, :radio, :checkbox, :submit, :image, :reset, and :file<br />
all matches input elements <strong>with</strong> their respective types.<br />
• :but<strong>to</strong>n matches all but<strong>to</strong>n elements and input elements of type but<strong>to</strong>n.