国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

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

2020-01-24 00:27:05
字體:
供稿:網(wǎng)友

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

實現(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();    }  }}

獲取更多代理,請訪問米撲代理:

http://proxy.mimvp.com

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

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 江安县| 通渭县| 青龙| 玉山县| 天全县| 甘谷县| 南郑县| 大港区| 蒙自县| 洛浦县| 安徽省| 兴城市| 四川省| 阿拉尔市| 高邮市| 东阿县| 丹阳市| 大荔县| 富民县| 大渡口区| 溧水县| 出国| 桓台县| 西林县| 商城县| 丁青县| 济南市| 广水市| 墨江| 友谊县| 襄城县| 湖口县| 聂拉木县| 崇礼县| 隆德县| 镇宁| 耒阳市| 木里| 木里| 阜城县| 泰宁县|