【发布时间】:2021-12-08 03:25:47
【问题描述】:
我尝试抓取产品的 productId,但我不能。请帮忙
html代码
<span class="info">
<button data-product="{"merchantName":"xxx","price":"11","productName":"car window","categoryName":"windows","brandName":"aa assosiations","productId":"which I want to scrape"}">
当我尝试时
h.ChildAttr("span.info>button", "data-product")
结果是{"merchantName":"xxx","price":"11","productName":"car window","categoryName":"windows","brandName":"aa assosiations","productId":"which I want to scrape"}
当我尝试时
h.ChildAttr("span.info>button", "productId")
没有结果。 如何使用 colly 获取这些数据?
【问题讨论】:
-
以前没用过go-colly,不过可能是
h.ChildAttr("span.info>button", "data-product.productId")? -
谢谢,但又没有结果。我认为 colly 不重要。 goquery 或任何用于解析 html 的方法都使用相同的方法,但我无法从 google 中找到
标签: html go web-scraping html-parsing go-colly