Đang chuẩn bị liên kết để tải về tài liệu:
Lấy toàn bộ url trong một webpage với ASP

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Chúng ta sẽ xây dựng một class đơn giản để lấy toàn bộ urls trong một web pageClass này có một public method: RetrieveUrls, method này lại gọi 2 private mothods khác: RetrieveContents và GetAllUrls RetrieveContents sẽ phát đi một request tới web page, và nhận lại nội dung của page. | Lấy toàn bộ url trong một webpage với ASP Chúng ta sẽ xây dựng một class đơn giản để lấy toàn bộ urls trong một web page Class này có một public method RetrieveUrls method này lại gọi 2 private mothods khác RetrieveContents và GetAllUrls RetrieveContents sẽ phát đi một request tới web page và nhận lại nội dung của page. GetAllUrls method sẽ dùng một expression đơn giản để tìm tất cả urls trong page sau đó in toàn bộ ra screen đồng thời cũng lưu vào file log. Dưới đây là toàn bộ code của class using System using System.Collections.Generic using System.Text using System.Net using System.IO using System.Text.RegularExpressions namespace FindAllUrls class GetUrls public method called from your application public void RetrieveUrls string webPage GetAllUrls RetrieveContent webPage get the content of the web page passed in private string RetrieveContent string webPage HttpWebResponse response null used to get response StreamReader respStream null used to read response into string try create a request object using the url passed in HttpWebRequest request HttpWebRequest WebRequest.Create webPage request.Timeout 10000 go get a response from the page response HttpWebResponse request.GetResponse create a streamreader object from the response respStream new StreamReader response.GetResponseStream get the contents of the page as a string and return it return respStream.ReadToEnd catch Exception ex houston we have a problem throw ex finally close it down we re going home response.Close

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.