Symfony Dom-crawler select nth-child of element

1.2k Views Asked by At

I am currently using symfony DOM-crawler for website scraping. I just wanna know how to select specific elements with the same class or name. I wanna use it also in tds.

here is the syntax I'm using currently:

$nameCrawler = $x_crawler->filter('.detail_text > .detail_info__content:nth-child(3) > p');

but it always return node empty. Is there anyway to achieve that? I can only scrape data from elements with a specific class name but elements with same class name I cannot scrape.

Here is the div structure:

<div class="parent">
    <div class="child">
        <p>test</p>
    </div>
    <div class="child">
        <p>test</p>
    </div>
    <div class="child">
        <p>test</p>
    </div>
    <div class="child">
        <p>test</p>
    </div>
    <div class="child">
        <p>test</p>
    </div>
</div>

lets say I want to get the p of 3rd child of class "child".

0

There are 0 best solutions below