cheerio-get-css-selector
Adds one extra function to cheerio: get a unique css selector.
When searching through the ancestors while building the selector the algorithm with stop at the closest element that has an id.
How to use:
Install the package:
npm install cheerio-get-css-selector
Init the library and pass it your cheerio object:
;
Use it as a method of cheerio objects:
$element;
Example
var cheerio = ;var GetUniqueSelector = ; var $ = cheerio;GetUniqueSelector; var $element = ; console; // outputs:#my-div > span > span:first-child