c#数据采集注意事项
2013-12-18 14:57
176 查看
HttpWebRequest httpWeb = (HttpWebRequest)HttpWebRequest.Create("http://ypk.39.net/yaopin/zc/liqi/7c872.html");
httpWeb.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";
httpWeb.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
httpWeb.ContentType = "application/x-www-form-urlencoded";
httpWeb.Method = "get";
httpWeb.CookieContainer = new CookieContainer();
httpWeb.KeepAlive = false;
HttpWebResponse httpRes = httpWeb.GetResponse() as HttpWebResponse;
Stream resStream = httpRes.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.GetEncoding("gb2312"));
string strCode = sr.ReadToEnd();
resStream.Close();
FileHelper.WriteFile("D://a.html", strCode);
httpWeb.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)";
httpWeb.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
httpWeb.ContentType = "application/x-www-form-urlencoded";
httpWeb.Method = "get";
httpWeb.CookieContainer = new CookieContainer();
httpWeb.KeepAlive = false;
HttpWebResponse httpRes = httpWeb.GetResponse() as HttpWebResponse;
Stream resStream = httpRes.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.GetEncoding("gb2312"));
string strCode = sr.ReadToEnd();
resStream.Close();
FileHelper.WriteFile("D://a.html", strCode);
相关文章推荐
- C#引用c++DLL结构体数组注意事项(数据发送与接收时)
- C#引用c++DLL结构体数组注意事项(数据发送与接收时)
- C#引用c++DLL结构体数组注意事项(数据发送与接收时)
- 【注意事项】c#通过CallBack获取C++传递的数据
- C#用大石头Xcode做数据底层注意事项
- C# 使用DateTimePicker与数据库中类型为datetime的数据作比较的一些注意事项
- 我们来讲下C#中的@符号的使用及注意事项。应用c#保留字
- SQLServer向Oracle转数据注意事项
- 构建安全的数据访问-设计注意事项(二)
- C#【2】串口编程:如果要自测,串接哪几个口?注意事项有些什么、并举例?
- 通过后台采集返回页面信息需要注意的事项
- 浅析基于ASP.NET网页的C#数据采集
- Oracle IMPDP导入数据案例之注意事项(undo/temp)
- MVC-Model数据注解(三)-Remote验证的一个注意事项
- C# 里所有的注意事项
- C#格式转换注意事项
- 51采集PCF8591数据通过ESP8266上传C#上位机
- 数据对象转json与md5加密注意事项
- 【读书笔记】iOS-本地文件和数据安全注意事项
- C# 在采集数据时的验证与登录处理