我想获得this page的源代码。
string adres = "https://betorder.com/Sports.html";
WebRequest gelenIstek = HttpWebRequest.Create(adres);
WebResponse gelenCevap;
using (gelenCevap = gelenIstek.GetResponse())
{
using (StreamReader donenDeger = new StreamReader(gelenCevap.GetResponseStream()))
{
string gelenBilgi = donenDeger.ReadToEnd();
string gonder = gelenBilgi;
div.InnerHtml = gonder;
}
}
答案 0 :(得分:0)
使用http
架构发出请求并将html添加到某个div,如下所示:
ASPX页面
<form id="form1" runat="server">
<asp:Panel runat="server" ID="pnlHtml"></asp:Panel>
</form>
您的代码隐藏:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var adres = "http://betorder.com/Sports.html";
var gelenIstek = HttpWebRequest.Create(adres);
WebResponse gelenCevap;
using (gelenCevap = gelenIstek.GetResponse())
{
using (var donenDeger = new StreamReader(gelenCevap.GetResponseStream()))
{
var response = donenDeger.ReadToEnd();
var divcontrol = new HtmlGenericControl
{
TagName = "div",
InnerHtml = response
};
pnlHtml.Controls.Add(divcontrol);
}
}
}