我正在使用以下方法从我的网站检索源代码-
class WorkerClass1
{
public static string getSourceCode(string url)
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
string sourceCode = sr.ReadToEnd();
sr.Close();
return sourceCode;
}
}
然后WorkerClass1
像这样实现-
private void button1_Click(object sender, EventArgs e)
{
string url = textBox1.Text;
string sourceCode = WorkerClass1.getSourceCode(url);
StreamWriter sw = new StreamWriter(@"path");
sw.Write(sourceCode);
sw.Close();
}
这很好用,可以从我的主页检索 HTML,但是一旦检索到第一页,我想在页面底部找到链接。
有没有办法可以修改我当前的代码来做到这一点?