我正在尝试找出是否可能以及使用什么代码:加载当前页面的内容并使用 PHP 或PHP Simple回显到特定页面(c.html)的相对路径,该页面在“#navbar a”中Html DOM 解析器。
到目前为止我的代码:
<?php
$pg = 'c.html';
include_once '%resource(simple_html_dom.php)%';
/* $cpath = $_SERVER['REQUEST_URI']; Old version */ // Path to current pg from root
$cpath = "http://www.".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
echo var_dump($cpath).": Current Root Path"."<br />"; // "http://www.partiproductions.com/copyr/index.php" - Correct
$cfile = basename($cpath);
echo 'Current File: ' . $cfile . "<br />"; // "index.php" - Current pg, Correct
$html = file_get_html($cpath); // Getting Warning: URL file-access is disabled in the server configuration & failed to open stream: no suitable wrapper could be found in.. & Fatal error: Call to a member function find() on a non-object in...
foreach($html->find(sprintf('#navbar a[href=%s]', $pg)) as $path) {
echo 'Path: ' . $path."<br />";
}
?>