【发布时间】:2020-05-13 09:07:15
【问题描述】:
我在解析网站数据时遇到问题。 下载 html 并加载它时,html 文档变为空。我也无法解析表中的任何数据,因为没有或在 html 文档中。行和列部分在表中,但它为空..
有人帮忙吗? 谢谢.. 这是我使用的代码;
Uri uri =new Uri("https://deprem.afad.gov.tr/sondepremler.html");
HttpWebRequest webClient = (HttpWebRequest)WebRequest.Create(uri);
webClient.Method = "GET";
webClient.ContentType = "text/html;charset=utf-8";
HtmlDocument doc = new HtmlDocument();
using (var response = (HttpWebResponse)webClient.GetResponse())
{
using (var stream = response.GetResponseStream())
{
doc.Load(stream, Encoding.GetEncoding("utf-8"));
}
}
var tds = doc.DocumentNode.SelectNodes("//table//tr//td");
这是从网站转过来的html文件;
<table id="resultTable" class="table table-striped" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th id="thDate">Tarih(TS)</th>
<th>Ajans</th>
<th>Enlem</th>
<th>Boylam</th>
<th>Derinlik</th>
<!--<th>Rms</th> -->
<th>Tip</th>
<th>Büyüklük</th>
<th>Ülke</th>
<th>İl</th>
<th>İlçe</th>
<th>Köy</th>
<th>Diğer</th>
<th>EventID</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
【问题讨论】:
-
我在你的 html 中没有看到任何 td 节点。
标签: c# html html-agility-pack