我正在尝试从下面提到的网站中提取价格。我正在使用AngleSharp进行提取。在网站上,价格如下(例如):
<span class="c-price">650.00 </span>
我正在使用以下代码进行提取。
using AngleSharp.Parser.Html;
using System.Net;
using System.Net.Http
//Make the request
var uri = "https://meadjohnson.world.tmall.com/search.htm?search=y&orderType=defaultSort&scene=taobao_shop";
var cancellationToken = new CancellationTokenSource();
var httpClient = new HttpClient();
var request = await httpClient.GetAsync(uri);
cancellationToken.Token.ThrowIfCancellationRequested();
//Get the response stream
var response = await request.Content.ReadAsStreamAsync();
cancellationToken.Token.ThrowIfCancellationRequested();
//Parse the stream
var parser = new HtmlParser();
var document = parser.Parse(response);
//Do something with LINQ
var pricesListItemsLinq = document.All
.Where(m => m.LocalName == "span" && m.ClassList.Equals("c-price"));
Console.WriteLine(pricesListItemsLinq.Count());
但是,我没有收到任何物品,但它们在网站上。我究竟做错了什么?如果AngleSharp不是推荐的方法,我应该使用什么?我应该使用什么代码?