{php}
$testurl = "https://auto.link.2898.com/index/Autochain/AutoChainYL?sign=2c2ddd62c5306ac0ba79ad0d85542f3b&id=460698&dtype=html&text=true&code=utf-8";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $testurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
curl_close($ch);
if ($output) {
$dom = new DOMDocument();
@$dom->loadHTML(mb_convert_encoding($output, 'HTML-ENTITIES', 'UTF-8')); // 使用 mb_convert_encoding 确保编码正确
$xpath = new DOMXPath($dom);
$links = $xpath->query('//a');
foreach ($links as $link) {
$url = $link->getAttribute('href');
$title = htmlspecialchars($link->nodeValue, ENT_QUOTES, 'UTF-8');
echo "<li class=\"link-item\"><a href=\"$url\" target=\"_blank\">$title</a></li>";
}
echo "<!--自助友链 " . date('Y-m-d H:i:s') . "-->";
} else {
echo "Curl error: Unable to fetch data.";
}
{/php}
仅存应用于本站的自助友情链接的展示。