發(fā)文章
發(fā)文工具
撰寫
網(wǎng)文摘手
文檔
視頻
思維導(dǎo)圖
隨筆
相冊(cè)
原創(chuàng)同步助手
其他工具
圖片轉(zhuǎn)文字
文件清理
AI助手
留言交流
private
byte
[] GetURLContents(
string
url)
{
// The downloaded resource ends up in the variable named content.
var content =
new
MemoryStream();
// Initialize an HttpWebRequest for the current URL.
var webReq = (HttpWebRequest)WebRequest.Create(url);
// Send the request to the Internet resource and wait for
// the response.
using
(WebResponse response = webReq.GetResponse())
// Get the data stream that is associated with the specified URL.
(Stream responseStream = response.GetResponseStream())
// Read the bytes in responseStream and copy them to content.
responseStream.CopyTo(content);
}
// Return the result as a byte array.
return
content.ToArray();
//該代碼片段來自于: http://www./codes/csharp/6577
來自: 悟靜 > 《.net和asp.net》
0條評(píng)論
發(fā)表
請(qǐng)遵守用戶 評(píng)論公約
winForm的淘寶請(qǐng)求之路
C#模擬網(wǎng)站頁(yè)面POST數(shù)據(jù)提交表單
HttpWebRequest簡(jiǎn)單實(shí)用封裝應(yīng)用類
HttpWebRequest簡(jiǎn)單實(shí)用封裝應(yīng)用類 很多時(shí)候我們要用HttpWebRequest組件模擬http協(xié)議發(fā)送web請(qǐng)求,封裝一個(gè)請(qǐng)求類看起來就很有必要了。
C#同步方法和異步方法的區(qū)別
C#同步方法和異步方法的區(qū)別 同步方法和異步方法的區(qū)別。這里主要是主程序等待異步方法,等待異步方法的結(jié)果。rs.一般都是已Begin開頭End結(jié)尾構(gòu)成一對(duì),異步委托方法,外加兩個(gè)回調(diào)函數(shù)和AsyncState參...
5種網(wǎng)絡(luò)爬蟲過程中,網(wǎng)頁(yè)去重方法的介紹!
5種網(wǎng)絡(luò)爬蟲過程中,網(wǎng)頁(yè)去重方法的介紹!一般的,我們想抓取一個(gè)網(wǎng)站所有的URL,首先通過起始URL,之后通過網(wǎng)絡(luò)爬蟲提取出該網(wǎng)頁(yè)中所有...
C# 實(shí)現(xiàn)http協(xié)議GET、POST請(qǐng)求類 - 大家新聞網(wǎng) - Powered by S...
public void DownloadFile(string url, string filename)public string Post(string url, string postData)public string Post(string url, byte[] postData)public string Post(string url, Multipart...
C# HttpWebRequest 通用類2 - 轉(zhuǎn) - afish1984 - 博客園
httpWebRequest = (HttpWebRequest)HttpWebRequest./// <summary> /// //獲取驗(yàn)證碼 /// </summary> /// <param name="server">服務(wù)器地址 </...
微信公眾平臺(tái)向特定用戶推送消息
public static string GetOpenidByFakeid(string fakeid) { try { CookieContainer cookie = null;
C# HTTP請(qǐng)求
public class HttpUtil { public static HttpResult HttpRequest(HttpItem httpItem) { HttpResult result = new HttpResult();try { Ht...
微信掃碼,在手機(jī)上查看選中內(nèi)容