国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > .NET > 正文

asp.net中獲取遠(yuǎn)程網(wǎng)頁(yè)的內(nèi)容之一(downmoon原創(chuàng))

2020-01-18 01:44:06
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
獲取遠(yuǎn)程網(wǎng)頁(yè)的內(nèi)容之一(downmoon原創(chuàng))
一、本機(jī)直接上網(wǎng)時(shí):
獲取指定遠(yuǎn)程網(wǎng)頁(yè)內(nèi)容#region 獲取指定遠(yuǎn)程網(wǎng)頁(yè)內(nèi)容
復(fù)制代碼 代碼如下:

        /**//// <summary> 
        /// 獲取指定遠(yuǎn)程網(wǎng)頁(yè)內(nèi)容 
        /// </summary> 
        /// <param name="strUrl">所要查找的遠(yuǎn)程網(wǎng)頁(yè)地址</param> 
        /// <param name="timeout">超時(shí)時(shí)長(zhǎng)設(shè)置,一般設(shè)置為8000</param> 
        /// <param name="enterType">是否輸出換行符,0不輸出,1輸出文本框換行</param> 
        /// <param name="EnCodeType">編碼方式</param> 
        /// <returns></returns> 
        ///  也可考慮 static string 

        public string GetRequestString(string strUrl,int timeout,int enterType,Encoding EnCodeType) 
        ...{ 
            string strResult; 
            try 
            ...{ 
                HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(strUrl) ; 
                myReq.Timeout = timeout; 
                HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse(); 
                Stream myStream = HttpWResp.GetResponseStream () ; 
                StreamReader sr = new StreamReader(myStream , EnCodeType); 
                StringBuilder strBuilder = new StringBuilder(); 

                while (-1 != sr.Peek()) 
                ...{ 
                    strBuilder.Append(sr.ReadLine()); 
                    if(enterType==1) 
                    ...{ 
                        strBuilder.Append(" "); 
                    } 
                } 
                strResult = strBuilder.ToString(); 
            } 
            catch(Exception err) 
            ...{ 
                strResult = "請(qǐng)求錯(cuò)誤:" + err.Message; 
            } 
            return strResult ; 
        } 

        #endregion 

二:通過(guò)域環(huán)境代理上網(wǎng)時(shí)這樣就不行了! 下篇文章分解,呵呵!
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 阜南县| 肃南| 永嘉县| 平果县| 桂阳县| 永平县| 庆云县| 彰化市| 长葛市| 桂东县| 巴楚县| 和平区| 荥阳市| 屯门区| 哈密市| 高阳县| 乌鲁木齐县| 贵州省| 叶城县| 六盘水市| 尉犁县| 烟台市| 女性| 宝鸡市| 东明县| 三都| 灵寿县| 广昌县| 定日县| 阜城县| 涞源县| 互助| 麟游县| 阳曲县| 仁布县| 四会市| 钟祥市| 依安县| 西华县| 天柱县| 广安市|