dotnetcore爬蟲(一)簡單獲取頁面資訊
阿新 • • 發佈:2018-12-07
我們就不多講理論了,直接拿出程式碼,嘗試嘗試就知道需要用到什麼知識了。
畢竟實踐是檢驗真理的唯一標準。
using System; using System.Net.Http; namespace dotnetcoreHttpClient { class Program { static void Main(string[] args) { HttpClient client = new HttpClient(new HttpClientHandler()); //獲取我們當前網站的dom var html = client.GetStringAsync("https://blog.csdn.net/qq_36051316/article/details/84380024").Result.ToString(); Console.WriteLine("輸出網站內容:"); Console.WriteLine("================華麗分割線=================="); System.Console.WriteLine(html); } } }