如何将 html 页面包含在另一个页面中并使其内容可抓取

How to include an html page in another page and have its contents be crawlable

我需要在另一个 html 页面中包含一个 html 页面,并且我希望包含页面 (page2.html) 的内容由 google 编制索引.我知道 iframe 不是解决方案,但搜索引擎如何处理 html 个对象:

document.getElementById("content").innerHTML = '<object type="text/html" data="page2.html"></object>';

对比jQuery:

$(function(){$("#content").load("page2.html"); });
// <script type="text/javascript" src="../common_files/js/jquery-2.1.3.min.js"></script>  <-- in header

对于 html:

<div id="content"></div>

?或者还有其他更好的解决方案吗?提前致谢。

如果您使用 javascript/jquery,google 无法 100% 保证内容会被抓取。

您需要在服务器端进行。 在 PHP 你可以使用 file_get_contents 函数得到 page2.html

$主页=file_get_contents('http://www.example.com/page2.html');

并将 $homepage 变量放入第一页。