<?php
$url = $_GET["url "];
// 创建一个curl资源
$ch = curl_init();
// 设置curl选项
curl_setopt($ch, CURLOPT_URL, $url); // 设置URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 将结果保存到变量而不是直接输出
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // 自动跟随重定向
// 执行请求并获取内容
$response = curl_exec($ch);
// 关闭curl资源
curl_close($ch);
// 从HTML中提取标题、关键词和描述
preg_match("/<title>(.*?)<\/title>/i", $response, $matches);
$title = $matches[1];
preg_match("/<meta\s+name=['\"]keywords['\"]\s+content=['\"](.*?)['\"]\s*\/?>/i", $response, $matches);
$keywords = $matches[1];
preg_match("/<meta\s+name=['\"]description['\"]\s+content=['\"](.*?)['\"]\s*\/?>/i", $response, $matches);
$description = $matches[1];
// 输出结果
echo "标题: " . $title . "<br>";
echo "关键词: " . $keywords . "<br>";
echo "描述: " . $description . "<br>";
?>