Asp.net C# 簡易版取得網頁指定標籤內容

SimpleCrawler
/** @brief SimpleCrawler 取得指定網頁的特定資料(簡易版爬蟲)
 * 先連線至網頁,並將其寫入資料流,輸出成字串。並依參數篩選後回傳字串。
 * @param url 網址、alpha 起始字串、omega 終止字串
 * @return 處理後網頁資料 
 * @author Weipartcles */
public string SimpleCrawler(string url, string alpha, string omega)
{
    try
    {
        HttpWebRequest myHttpWebRequest = (HttpWebRequest)(WebRequest.Create(url));
        WebResponse myWebResponse = myHttpWebRequest.GetResponse();
        StreamReader sr = new StreamReader(myWebResponse.GetResponseStream(),
                                           System.Text.Encoding.Default); // 有亂碼改這
        string htmlstr = sr.ReadToEnd();
        sr.Close();
        
        int positionAlpha = htmlstr.IndexOf(alpha) + alpha.Length;
        int positionOmega = htmlstr.IndexOf(omega, positionAlpha);

        string target = htmlstr.Substring(positionAlpha, positionOmega - positionAlpha);
        //return positionAlpha + "<br>" + positionOmega + "<br>" + target;
        return target;
    }
    catch (Exception ex)
    {
        return ex.ToString();
    }
}
MultipleCrawler
/** @brief MultipleCrawler 取得指定網頁的特定資料(簡易版爬蟲)
 * 先連線至網頁,並將其寫入資料流,輸出成字串。並依參數進行切割後回傳。
 * 將會重複搜尋符合條件的區塊並放進List,直到文件底部為止。
 * @param url 網址、alpha 起始字串、omega 終止字串
 * @return 處理後網頁資料的List */
public List<string> MultipleCrawler(string url, string alpha, string omega)
{
    List<string> targetlist = new List<string>();
    try
    {
        HttpWebRequest myHttpWebRequest = (HttpWebRequest)(WebRequest.Create(url));
        WebResponse myWebResponse = myHttpWebRequest.GetResponse();
        StreamReader sr = new StreamReader(myWebResponse.GetResponseStream(),
                                           System.Text.Encoding.Default); // 有亂碼改這
        string htmlstr = sr.ReadToEnd();
        sr.Close();

        int step = 0;
        int positionAlpha = 0;
        int positionOmega = 0;
        string target = "";

        // 搜索迴圈,直到巡至最後一個
        do
        {
            positionAlpha = htmlstr.IndexOf(alpha, step) + alpha.Length;
            positionOmega = htmlstr.IndexOf(omega, positionAlpha);
            step = positionOmega;
            target = htmlstr.Substring(positionAlpha, positionOmega - positionAlpha);
            targetlist.Add(target);
        }
        while (htmlstr.IndexOf(alpha, step) != htmlstr.LastIndexOf(alpha));

        // 將最後一個補上
        positionAlpha = htmlstr.IndexOf(alpha, step) + alpha.Length;
        positionOmega = htmlstr.IndexOf(omega, positionAlpha);
        target = htmlstr.Substring(positionAlpha, positionOmega - positionAlpha);
        targetlist.Add(target);
        
        return targetlist;
    }
    catch (Exception ex)
    {
        targetlist.Add(ex.ToString());
        return targetlist;
    }
}