Closed k1ng440 closed 3 years ago
What result you've got and what result you expect?
i expect to get 1 with $("[name=commit]").length;
but got 0
var cheerio = require('cheerio');
var $ = cheerio.load(require('fs').readFileSync('cheerio_issue729.html','utf-8'));
console.log($("[name=commit]").length);
console.log($("[href='/shop/accessories/supreme-braun-travel-alarm-clock']").length);
Where cheerio_issue729.html
is your html.
Output:
1
1
I have cheerio@0.19.0
. What version you are testing?
strange i am also using the same version
"cheerio": "^0.19.0"
Re-check data. Maybe in your script download of html fails?
The best thing you can do is to create a standalone JavaScript file that demonstrates this problem, HTML and all. It's a little tedious to write markup in a string literal in JavaScript, but it's the most reliable way to ensure we're not dealing with data issues like the one @pyhedgehog has mentioned. If in the process, you can eliminate any markup that is not necessary to trigger the bug, that would help us, too!
I am having issue with this page because its has multiple button named commit in
<script>
tags$("[name=commit]")