是否可以从 page_load 请求互联网上的另一个页面?我的意思是是否可以从另一个页面获取包含信息的标记代码并将其显示在我的 aspx 网站上?例如这样的事情:
protected void Page_Load(object sender, EventArgs e)
{
UnknownType anotherSite = GetMarkupCode("www.fifa.com");
//parse anotherSite
.
.
.
//display parsed informations
.
.
.
}
如果可以的话我该怎么做?非常感谢您的回答。
最佳答案
用户可以使用WebClient类。
WebClient webClient = new WebClient();
Stream data = webClient.OpenRead("http://www.fifa.com");
StreamReader streamReader = new StreamReader(data);
string html = streamReader.ReadToEnd();
编辑:感谢卢卡斯的更简单版本
WebClient webClient = new WebClient();
string html = webClient.DownloadString("http://www.fifa.com");
关于c# - 从 aspx 站点请求另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2673192/