【发布时间】:2013-05-31 17:47:04
【问题描述】:
在某些内容被某些 jquery 更新后,我想获取加载到 webview 中的页面的实际内容
$(document).ready(function() {
$("#main").append('<p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p><p>Test</p>');
});
页面更新后,我尝试使用以下命令 [vala syntax] 获取页面内容
web_view.get_main_frame ().get_data_source().get_data().str
但我只得到原始内容(即使加载完成)
使用
web_view.get_dom_document().document_element.text_content
我得到了实际内容,但标签被删除了。
我想我可以遍历整个树来获取实际文档,但应该是更简单的方法。
编辑: 我的解决方案
this.web_view.load_finished.connect ((source, frame) => {
stderr.printf(this.web_view.get_dom_document().body.get_inner_html());
}
几年后当我读到这篇文章时,我可能会觉得这很糟糕,但现在我会继续这样做。
【问题讨论】: