1 方法

               System.Net.WebClient aWebClient = new System.Net.WebClient();
aWebClient.Encoding = System.Text.Encoding.Default;
Byte[] pageData = aWebClient.DownloadData(url); string nhtml = Encoding.GetEncoding("utf-8").GetString(pageData);

2方法

                System.Net.WebClient aWebClient = new System.Net.WebClient();
aWebClient.Encoding = System.Text.Encoding.Default;
string nhtml = aWebClient.DownloadString(goodstidurl);

3方法

               WebBrowser webbrowser = new WebBrowser();
StreamReader sr = new StreamReader(this.webBTaobao.DocumentStream, Encoding.Default);
html = sr.ReadToEnd();
html = html.Replace("\r\n", "");
html = html.Replace("\n", "");
html = html.Replace(" ", "");
html = html.Replace("(", "");
html = html.Replace(")", "");
string nurl = Regex.Match(html, "(?<=data-url=\").*?(?=\")").Value;
//新建一个WebBrowser
WebBrowser webAddress = new WebBrowser();
webAddress.Navigate(nurl);
//等待载入完毕
while (webAddress.ReadyState < WebBrowserReadyState.Complete) Application.DoEvents();
StreamReader sraddress = new StreamReader(webAddress.DocumentStream, Encoding.Default);
jsonaddress = sraddress.ReadToEnd();

4方法

            WebRequest hwr = WebRequest.Create(@"http://item.taobao.com/item.htm?

id=" + row["urlId"].ToString());//向指定Url发出请求
HttpWebResponse hwp = hwr.GetResponse() as HttpWebResponse;//将hwr对HTTP的请求
string text;
StreamReader sr;
string code = hwp.ContentType;//请求响应得到的内容类型
//得到编码了
code = code.Split('=')[1];
Stream rep = hwp.GetResponseStream();//将请求得到的内容以流的形式读出
sr = new StreamReader(rep, Encoding.GetEncoding(code));//用指定的字符编码为指定的流初始化

最新文章

  1. 修改C:\WINDOWS\system32\drivers\etc\hosts 文件有什么作用
  2. 软件打开时间、窗体透明度、背景色---《用delphi开发共享软件》-15.1任务管理器
  3. Lua协程
  4. LINQ SQL分组取最近一条记录
  5. js封装,一个JS文件引用多个JS文件
  6. 对于python的内存管理的好文章
  7. Drools引擎学习
  8. centos6.4 ceph安装部署之ceph object storage
  9. UVA 11080 - Place the Guards(二分图判定)
  10. android台 cocos2d-x 翻阅相册数据
  11. WebApi2 文件图片上传下载
  12. Windows 定时任务对数据库进行操作
  13. 【学习总结】GirlsInAI ML-diary day-15-读/写txt文件
  14. 《深入理解java虚拟机》读书笔记——垃圾收集与内存分配策略
  15. Layui 写一个简单的后台页面
  16. 四种对话框(dialog)的简单使用方法
  17. 题解 P2580 【于是他错误的点名开始了】
  18. eclipse JRE(unbound)问题
  19. ubuntu 16.04 appstreamcli 问题
  20. Code Quality

热门文章

  1. [BOI2011]MET-Meteors
  2. BZOJ 1415 [NOI2005]聪聪与可可 (概率DP+dfs)
  3. WIN10 java环境变量问题之 配置的JDK1.8版本却是1.7
  4. SpringBoot中打包设置,将配置文件打包在外部
  5. [Tools] Using mobile device for debugging your mobile web site
  6. [Angular] Set Metadata in HTTP Headers with Angular HttpHeaders
  7. cocos2d-x 移植到android中编译的一些问题:fatal error: Box2D/Box2D.h: No such file or directory&amp;quot;
  8. Hive编程指南_学习笔记01
  9. 为QML创建C++插件(下载)
  10. (八)统一配置中心-Config