我正在做一個抓取專案,我在這個 URL 的幫助下抓取谷歌地圖評論:
https://www.google.com/async/reviewDialog?hl=en&async=feature_id:0x47e66e2964e34e2d:0x8ddca9ee380ef7e0,sort_by:,start_index:,associated_topic:,_fmt:pc
并用cheerio決議它:
$('.lcorif').each((i,el) => {
rating[i] = $(el)
.find(".EBe2gf").attr("aria-label")
console.log(i)
console.log(rating) //it gives me only first rating
})
如何以正確的方式獲得所有用戶的評分?
uj5u.com熱心網友回復:
所以我發現父選擇器標簽只迭代回圈一次,所以我使用了這個:
$('.gws-localreviews__google-review').each((i,el) => {
rating[i] = $(el)
.find(".EBe2gf").attr("aria-label")
})
我得到了所有用戶的評分。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/486872.html
標籤:javascript 网页抓取 切里奥
