0
string searchString = textBox1.Text.Replace(" ", "%20");
string url = "http://sometorrentsearchurl.com/search/" + searchString + "/0/99/401";
HttpWebRequest oReq = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)oReq.GetResponse();
var doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(resp.GetResponseStream());
foreach (HtmlNode torrent in doc.DocumentNode.SelectNodes("//tr"))
{
foreach (HtmlNode title in torrent.SelectNodes(".//a[@class='detLink']"))
{
Label tTitle = new Label();
tTitle.Text = title.InnerText;
tTitle.Location = new Point(133, tHeightLoc);
tTitle.BackColor = Color.Transparent;
tTitle.ForeColor = Color.White;
tTitle.AutoSize = false;
tTitle.Font = new Font("Arial", 10);
tTitle.Size = new Size(347, 25);
tTitle.TextAlign = ContentAlignment.MiddleLeft;
tTitle.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
panel2.Controls.Add(tTitle);
tHeightLoc += 45;
}
}
我试图从一个网站和每一个HTML th
标签获得种子的列表中找到我要创建我的形式某些控件与其他孩子HTML标签中获得的值,但此行会返回一个错误foreach (HtmlNode title in torrent.SelectNodes(".//a[@class='detLink']"))
的Html敏捷包foreach循环错误
我想知道如何解决它,因为是第一次,我使用HTML敏捷性包。
不需要共享错误的详细信息,因为我们是读心术。 – Oded
@Oded对象引用未设置为对象的实例。 – Paradox
然后你试图引用对象为null。究竟哪一行发生? – ChrisK