zoukankan      html  css  js  c++  java
  • C# 模拟浏览器请求

          public string getHtml(string Url, string type = "UTF-8")
            {
                try
                {
                    System.Net.HttpWebRequest wReq = (HttpWebRequest)System.Net.HttpWebRequest.Create(Url);
                    wReq.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0";     //  。。。
                    System.Net.HttpWebResponse wResp = (HttpWebResponse)wReq.GetResponse();
                    System.IO.Stream respStream = wResp.GetResponseStream();
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(respStream, Encoding.GetEncoding(type)))
                    {
                        return reader.ReadToEnd().Replace(" ", "").Replace(" ", "");
                    }
                }
                catch (System.Exception ex)
                {
                }
                return "";
            }

  • 相关阅读:
    随机点名系统
    JQuery
    百度搜索下拉提示
    正则表达式
    严格模式
    CSS引入方式有哪些,区别是什么
    Js中的函数
    float浮动造成高度塌陷的解决办法
    PC端页面开发基础-问题总结(一)
    PC端页面开发基础-IE6常见CSS解析Bug及Hack
  • 原文地址:https://www.cnblogs.com/it1042290135/p/5577495.html
Copyright © 2011-2022 走看看