如果您不想通过 iFrame 包含整个插件,该插件已经使用了很多脚本,并且该站点更像是一个包含本地体育俱乐部结果或其他“只读”信息的表格,您可以使用php和file_get_contents(),导入iframe。现在您可以对其内容进行样式化并通过 jQuery 定位它们。
例如,您有以下标记:
<html>
<!-- Some Head and Body parts, like navigation, sidebar, etc. -->
<div id="results">
<!-- Lots of results -->
</div>
</html>
您可以定位id="result 来识别要导入的部分的开头。
让我们定义你的目标:
$host = 'http://sportclub.de/results.html';
并导入他:
$filestring = file_get_contents($host);
由于您不想导入整个 url,您需要设置起点和终点。为了给你一个基本的想法,这是一个代码,它的工作方式类似于上面提到的概念:
<?php
$host = 'http://sportclub.de/results.html';
$filestring = file_get_contents($host);
$startpos = 0; //erstes Zeichen
while($pos = strpos($filestring, "<div id=\"results\"", $startpos))
{
$string = substr($filestring, $pos, strpos($filestring, "</div>", $pos + 1) - $pos);
echo $string."</div>";
$startpos = $pos + 1;
}
$string = preg_replace("/(^¦\s)(http:\/\/)?(www\.)?[\.0-9a-zA-Z\-_~]+\.(com¦net¦org¦info¦name¦biz¦.+\.\w\w)((\/)?[0-9a-zA-Z\.\-_~#]+)?\b/ie","",$string);
?>