主頁(yè) > 知識(shí)庫(kù) > 用asp.net實(shí)現(xiàn) 取頁(yè)面中的所有鏈接

用asp.net實(shí)現(xiàn) 取頁(yè)面中的所有鏈接

熱門(mén)標(biāo)簽:鐵路電話系統(tǒng) 美圖手機(jī) 智能手機(jī) 網(wǎng)站文章發(fā)布 檢查注冊(cè)表項(xiàng) 銀行業(yè)務(wù) 服務(wù)器配置 呼叫中心市場(chǎng)需求
private void Page_Load(object sender, System.EventArgse) 
  { 
   //在此處放置用戶代碼以初始化頁(yè)面 

   string url =https://www.jb51.net; 
   System.Net.HttpWebRequesthttpReq; 
   System.Net.HttpWebResponsehttpRes; 
   System.UrihttpURL = new Uri(url); 
   httpReq =(System.Net.HttpWebRequest)System.Net.WebRequest.Create(httpURL); 
   httpReq.Method= "GET"; 
   httpRes= (System.Net.HttpWebResponse)httpReq.GetResponse(); 
   httpReq.KeepAlive= false; 
   System.IO.StreamReadersReader = newSystem.IO.StreamReader(httpRes.GetResponseStream(),System.Text.Encoding.GetEncoding("GB2312")); 
   stringres = sReader.ReadToEnd(); 
   //以下是利用正則表達(dá)式對(duì)獲取的文本流進(jìn)行過(guò)濾 
   stringstrRegex = @"a.+?a>"; 
   System.Text.RegularExpressions.Regexr; 
   System.Text.RegularExpressions.MatchCollectionm; 
   r = newSystem.Text.RegularExpressions.Regex(strRegex,System.Text.RegularExpressions.RegexOptions.IgnoreCase); 
   m =r.Matches(res); 
   Response.Write("該頁(yè)共有"+m.Count + " 個(gè)超連接br/>"); 
   for (inti = 0; i  m.Count; i++) 
   { 
    Response.Write(m[i].Value+ "br/>"); 
   } 
  } 

標(biāo)簽:新疆 長(zhǎng)治 樂(lè)山 沈陽(yáng) 上海 滄州 紅河 河南

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用asp.net實(shí)現(xiàn) 取頁(yè)面中的所有鏈接》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266