cheerio icon indicating copy to clipboard operation
cheerio copied to clipboard

Cannot select the current element inside extract

Open T0nd0Tara opened this issue 1 month ago • 0 comments

Some times you have a structure like

<div>
  <a href="www.google.com">
    <div class="info">Google</div>
  </a>
  <a href="www.duckduckgo.com">
    <div class="info">Duck Duck Go</div>
  </a>
</div>

It'd be convenient to be able to do something like

$.extract({
  engines: [{
    selector: "div > a",
    value: {
      url: {
        selector: ":scope", // <-- Here is the problem
        value: "href"
      },
      info: '.info'
    }
  }]
})

T0nd0Tara avatar Dec 06 '25 17:12 T0nd0Tara