c#static string GetHttp(string URL_Input)
{
    try
    {
        WebClient MyWebClient = new WebClient();
        MyWebClient.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
        MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
        try
        {
            Byte[] pageData = MyWebClient.DownloadData(URL_Input); //从指定网站下载数据
            string data = Encoding.UTF8.GetString(pageData);
            return data;
        }
        catch (Exception e)
        {
            Console.WriteLine(e.Message);
        } 
    }
    catch (Exception ep)
    {
        Console.WriteLine(ep.Message);
    }
    return "";
}
本文作者:Kellermen
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!