라이브러리를 보지 못했지만 매우 간단합니다. 나는 당신을 도울 수있는 빠른 기능을 적어 두었습니다.
<?php
function getLinkInfo($url)
{
// Get target link html
$html = file_get_contents($url);
// Prepare the DOM document
$dom = new DOMDocument();
$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
// Get page title
$titles = $dom->getElementsByTagname('title');
foreach ($titles as $title) {
$linkTitle = $title->nodeValue;
}
// Get META tags
$metas = $dom->getElementsByTagname('meta');
// We only need description
foreach ($metas as $meta) {
if ($meta->getAttribute("name") == "description") {
$linkDesc = $meta->getAttribute("content");
}
}
// Get all images
$imgs = $dom->getElementsByTagname('img');
// Again, we need the first one only
foreach ($imgs as $img) {
$firstImage = $img->getAttribute("src");
if (strpos("http://", $firstImage) === false) {
$firstImage = $url . $firstImage;
}
break;
}
$output = <<<HTML
<div class="info">
<div class="image"><img src="{$firstImage}" alt="{$linkTitle}" /></div>
<div class="desc">
<div class="title">{$linkTitle}</div>
<div class="subtitle">{$url}</div>
<div class="summary">{$linkDesc}</div>
</div>
</div>
HTML;
return $output;
}
echo getLinkInfo("http://www.phpfour.com/");
감사합니다. 이제 코드를 ASP에서 코딩하는 방법을 알아 봅니다. – edude05