欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# 利用代理爬蟲網(wǎng)頁(yè)的實(shí)現(xiàn)方法

 更新時(shí)間:2017年10月11日 14:51:26   投稿:lqh  
這篇文章主要介紹了C# 利用代理爬網(wǎng)頁(yè)的實(shí)現(xiàn)方法的相關(guān)資料,希望通過本能幫助到大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下

C# 利用代理爬蟲網(wǎng)頁(yè)

實(shí)現(xiàn)代碼:

// yanggang@mimvp.com
// http://proxy.mimvp.com
// 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.com");
      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://www.baidu.com");
      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();
    }
  }
}

獲取更多代理,請(qǐng)?jiān)L問米撲代理:

http://proxy.mimvp.com

如有疑問請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論