如何使用 asp.net 中的页面 URL 以编程方式读取 html 页面的内容? 例如,我需要读取我的 facebook url 的内容,例如:https://www.facebook.com/mano1822
最佳答案
您必须向相应的 URL 发出 HTTP 请求并解析响应。我建议使用 this MSDN article 作为引用,它也有很好的例子。
编辑: 下面发布的代码来自特定帖子:
WebRequest request = WebRequest.Create("http://testserver/testpage");
//If the target server requires authentication, you have to give some credentials in
//your request object. The way you pass these credentials depends on the authentication
//mechanism of the server...
WebResponse response = request.GetResponse();
Stream dataStream = response.GetResponseStream ();
//use dataStream to read data from the server
response.Close();`
希望我有帮助!
关于c# - 如何使用asp.net中的页面URL以编程方式读取html页面的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20310383/