发文章
发文工具
撰写
网文摘手
文档
视频
思维导图
随笔
相册
原创同步助手
其他工具
图片转文字
文件清理
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条评论
发表
请遵守用户 评论公约
winForm的淘宝请求之路
C#模拟网站页面POST数据提交表单
HttpWebRequest简单实用封装应用类
HttpWebRequest简单实用封装应用类 很多时候我们要用HttpWebRequest组件模拟http协议发送web请求,封装一个请求类看起来就很有必要了。
C#同步方法和异步方法的区别
C#同步方法和异步方法的区别 同步方法和异步方法的区别。这里主要是主程序等待异步方法,等待异步方法的结果。rs.一般都是已Begin开头End结尾构成一对,异步委托方法,外加两个回调函数和AsyncState参...
5种网络爬虫过程中,网页去重方法的介绍!
5种网络爬虫过程中,网页去重方法的介绍!一般的,我们想抓取一个网站所有的URL,首先通过起始URL,之后通过网络爬虫提取出该网页中所有...
C# 实现http协议GET、POST请求类 - 大家新闻网 - 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 - 转 - afish1984 - 博客园
httpWebRequest = (HttpWebRequest)HttpWebRequest./// <summary> /// //获取验证码 /// </summary> /// <param name="server">服务器地址 </...
微信公众平台向特定用户推送消息
public static string GetOpenidByFakeid(string fakeid) { try { CookieContainer cookie = null;
C# HTTP请求
public class HttpUtil { public static HttpResult HttpRequest(HttpItem httpItem) { HttpResult result = new HttpResult();try { Ht...
微信扫码,在手机上查看选中内容