这里的想法是允许调用者AfterHTMLPieceHandler
为循环的每个循环实现,我不知道它是否完全正确或者它应该是一个事件 insted 或委托。老实说,我不知道有什么区别,但这是另一个问题。
//? Should it be static?
public static class PageScan
{
public delegate string AfterHTMLPieceHandler();
public static string GetHTML(string url)
{
HttpWebRequest wRequest = (HttpWebRequest)WebRequest.Create(url);
wRequest.Method = "GET";
HttpWebResponse wResponse = (HttpWebResponse)wRequest.GetResponse();
StreamReader sReader = new StreamReader(wResponse.GetResponseStream());
string html = sReader.ReadToEnd();
sReader.Close();
wResponse.Close();
sReader.Dispose();
return html;
}
public static void GetPiecesOfHtml(string html, string constantHtml)
{
while (html.IndexOf("http://portfoliopad.com/images/") > -1)
{
// it will retrieve a piece of html given the constantHtml and remove from html in order to break the loop in the end
//How Do I hit the event for each time one cycle of the loop ends?
}
}
}