我以http://www.bxwx.org/bsort1/0/1.htm為例測試的,目的是獲取這個頁面所有的小說標題,但是以下面這段代碼只能獲取匹配到的第一個標題(也就是“特種教師”,下面是“百煉成仙”這個就取不到了),怎樣才能取得他所有的標題呢,正則表達式是我自己寫的,在正則測試工具上能夠獲取這個頁面的所有標題,不過放到VS上就只能取第一個匹配的內容public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { TextBox2.Text = null; TextBox2.Text = GetPageCode(Textbox1.Text, ""); } public String GetPageCode(String PageURL, String Charset) { //讀取目標頁面編碼 string webEncode = DropDownList1.SelectedItem.Text; //存放目標網頁的html String strHtml = ""; WebRequest wreq = WebRequest.Create(PageURL); HttpWebResponse wresp = (HttpWebResponse)wreq.GetResponse(); return strHtml; } }
- 2 回答
- 0 關注
- 753 瀏覽
添加回答
舉報
0/150
提交
取消