c# - 如何使用asp.net中的页面URL以编程方式读取html页面的内容?

标签 c# asp.net asp.net-mvc

如何使用 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/

相关文章:

asp.net - 从 WebAppService 访问 Azure 文件共享

Asp.Net 5(核心)RC1 : How to log to file (rolling file logging) [DNX Core 5 compatible solution]?

c# - 是否可以查询查询?

javascript - mvc3 验证输入 'not-equal-to'

c# - 为什么我的 ReactiveUserControl 或 ReactUI 应用程序无法使用 Selenium 自动测试和 WinAppDriver(C# 测试解决方案)

c# - 无法在自宿主应用程序中配置新程序集

c# - 是否可以为 Windows 8 Surface RT 创建本地 Web 服务器

jQuery DataTables - 响应表头不适用于 asp gridview

asp.net-mvc - 在 ASP.NET MVC 中构建复杂的 Web 表单

c# - 字符转换与 Convert.ToChar()