好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C# 利用代理爬虫网页的实现方法

C# 利用代理爬虫网页

实现代码:

?

// yanggang@mimvp测试数据

// http://proxy.mimvp测试数据

// 2015-11-09

 

using System;

using System.IO;

using System.Net;

using System.Text;

 

namespace ConsoleApplication1

{

   class Program

   {

     public static void Main( string [] args)

     {

       System.Net.WebProxy proxy = new WebProxy( "218.21.230.156" , 443);    // "107.150.96.188", 8080

       HttpWebRequest request = (HttpWebRequest)WebRequest.Create( "http://proxy.mimvp测试数据" );

       request.Proxy = proxy;

       using (WebResponse response = request.GetResponse())

       {

         using (TextReader reader = new StreamReader(response.GetResponseStream()))

         {

           string line;

           while ((line = reader.ReadLine()) != null )

             Console.WriteLine(line);

         }

       }

     }

 

     public static void Main2()

     {

       // your code goes here

       System.Net.WebProxy proxy = new WebProxy( "107.150.96.188" , 8080);

       System.Net.HttpWebRequest req = (HttpWebRequest)WebRequest.Create( "http://HdhCmsTestbaidu测试数据" );

       req.Proxy = proxy;

       req.Timeout = 30 * 1000;

       System.Net.HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

       Encoding bin = Encoding.GetEncoding( "UTF-8" );

       StreamReader reader = new StreamReader(resp.GetResponseStream(), bin);

       string str = reader.ReadToEnd();

       Console.WriteLine(str);

     

       reader.Close();

       reader.Dispose();

     }

   }

}

获取更多代理,请访问米扑代理:

http://proxy.mimvp测试数据

如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

原文链接:https://blog.mimvp测试数据/2015/12/c-proxy-crawl-page/

dy("nrwz");

查看更多关于C# 利用代理爬虫网页的实现方法的详细内容...

  阅读:50次