!-- publish_helper name='要聞-新聞' p_id='1' t_id='850' d_id='1' -->
內容。。。。
!-- publish_helper name='要聞-財經' p_id='30' t_id='98' d_id='1' -->
protected void Enter_Click(object sender, EventArgs e)
{
WebClient we = new WebClient(); //主要使用WebClient類
byte[] myDataBuffer;
myDataBuffer = we.DownloadData(txtURL.Text); //該方法返回的是 字節數組,所以需要定義一個byte[]
string download = Encoding.Default.GetString(myDataBuffer); //對下載的數據進行編碼
//通過查詢源代碼,獲取某兩個值之間的新聞內容
int startIndex = download.IndexOf("!-- publish_helper name='要聞-新聞' p_id='1' t_id='850' d_id='1' -->");
int endIndex = download.IndexOf("!-- publish_helper name='要聞-財經' p_id='30' t_id='98' d_id='1' -->");
string temp = download.Substring(startIndex, endIndex - startIndex + 1); //截取新聞內容
lblMessage.Text = temp;//顯示所截取的新聞內容
}