【问题标题】:Get html content from multiple pages and write into new page从多个页面获取html内容并写入新页面
【发布时间】:2021-02-13 00:23:22
【问题描述】:

我需要打开多个窗口并获取html内容,然后我要推送或写入 新的 html 页面。这可能吗?

示例:Sample window-click here 我们有 window1 和 window2 (见提到的图片)。 Window1 包含paragraph1,Window2 包含paragraph2, 我需要得到这第1和2段,写入window3

我有编写新窗口的代码,请建议或帮助实现我的要求?

我的代码:

var url = document.getElementById('ifrmDivisionPage').src;
var tabOrWindow = window.open(url, '_blank');
tabOrWindow.document.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" );
tabOrWindow.document.write( "<html>" );
tabOrWindow.document.write( "<head>" );
tabOrWindow.document.write( "<meta charset='utf-8'>" );
tabOrWindow.document.write("</head><body>");
tabOrWindow.document.write($("#ifrmDivisionPage").contents().find("body").html());
tabOrWindow.document.write("</body>");
 tabOrWindow.document.write("</html>");

【问题讨论】:

标签: javascript jquery html dom


【解决方案1】:

是的。这个有可能。您可以使用多种方法来做到这一点。网络爬虫和网络爬虫技术将在这里为您提供帮助。例如,尝试在 iframe 中加载必要的 URL,而不在不同的窗口中打开它们,然后您可以轻松访问它们的 DOM 元素。然后只需使用简单的 javascript 获取必要的内容并将它们应用到任何你想要的地方。

【讨论】:

  • 我尝试了很多方法。但我无法使用java脚本实现
猜你喜欢
  • 2021-12-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-10
相关资源
最近更新 更多