如何从另一个网站获取IFrame的InnerText?
我正在尝试对网站进行一些屏幕抓取。我想要获取的内容位于 IFrame 内部。如何获取 IFrame 内显示的 InnerText 或 HTML?
我正在使用 .Net 4.0 和 C#。我希望能够从 WinForm 中执行此操作。
我尝试过这个,但找不到从哪里获取实际数据...
void PageCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser b = sender as WebBrowser;
string response = b.DocumentText;
HtmlElement element = b.Document.GetElementById("profileFrame");
if (element != null)
{
// do something with the data
}
}
我尝试搜索 element
但找不到任何 HTML。这可能吗?
I am trying to do some screen-scraping of a website. The content that I want to get is inside of an IFrame. How do I get the InnerText or HTML that is being displayed inside of the IFrame?
I am using .Net 4.0 and C#. I want to be able to do this from a WinForm.
I tried this, but can't find where to get the actual data from...
void PageCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser b = sender as WebBrowser;
string response = b.DocumentText;
HtmlElement element = b.Document.GetElementById("profileFrame");
if (element != null)
{
// do something with the data
}
}
I've tried searching through the element
but couldn't find any of the HTML. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iframe 的内容不包含在第一个文档中。您需要向 iframe 的源地址发出第二次请求才能获取 iframe 中显示的内容。
The contents of the iframe isn't included in the first document. You would need to make a second request to the source address of the iframe to get the content displayed in the iframe.