我正在尝试使用 AngleSharp 在 walmart.com 上抓取一些页面,但由于某种原因它无法正常工作。过去我一直在使用 AngleSharp 抓取许多网站,没有任何问题,但在这里它就不行了。
为简单起见,这里有一页:https ://www.walmart.com/ip/50908276 ,我正在尝试获取商品的价格(目前为 9.99 美元)。在 Chrome 的控制台中,当我键入时,document.getElementsByClassName("Price-characteristic")
我会得到一个包含 60 个[span.Price-characteristic]
结果的列表。完美的。但是,当我尝试使用 AngleBrackets 进行相同操作时,它不会返回任何内容。
这是我的代码:
using AngleSharp;
using AngleSharp.Dom;
public async void GetPrice()
{
var config = Configuration.Default.WithDefaultLoader();
string address = "https://www.walmart.com/ip/50908276";
IDocument document = await
BrowsingContext.New(config).OpenAsync(address);
var priceDollar = document.GetElementsByClassName("Price-characteristic");
}
我对 HTML 不太熟悉,所以我为任何明显的无知道歉。