1. C# 

 通过 WebClient 类,使用方法如下: 

 

using System;
using System.Net;
using System.IO;

public class Test
{
    public static void Main (string[] args)
    {
        if (args == null || args.Length == 0)
        {
            throw new ApplicationException ("Specify the URI of the resource to retrieve.");
        }
        WebClient client = new WebClient ();

        // Add a user agent header in case the 
        // requested URI contains a query.

        client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

        Stream data = client.OpenRead (args[0]);
        StreamReader reader = new StreamReader (data);
        string s = reader.ReadToEnd ();
        Console.WriteLine (s);
        data.Close ();
        reader.Close ();
    }
}
View Code

相关文章:

  • 2022-12-23
  • 2021-11-24
  • 2021-07-13
  • 2021-12-06
  • 2022-02-27
  • 2021-04-09
  • 2021-10-20
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2021-12-12
  • 2022-02-01
  • 2021-11-18
  • 2022-01-09
相关资源
相似解决方案