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