2013-04-22 52 views
-2

嗨,我正在一個項目。在這個項目中,我需要另一個網站元內容。 這裏有一個例子如何獲得另一個網站的元內容

這是遠程的網站中繼內容

<meta content="Kültür Sanat Edebiyat Portalı. Geniş Türkçe şiir ve şair arşivi. Yarışmalar, şiir etkinlikleri, sanat haberleri. Kitaplar ile ilgili geniş ve detaylı tanıtımlar. Resim tiyatro sergi." name="description"> 

我想PHP的file_get_contents

<?php 
$homepage = file_get_contents('http://antoloji.com/'); 
echo $homepage; 
?> 

但coulnot找到一種方法如何只拿元的內容(說明部分) 感謝你的建議

回答

4

PHP有一個非常有用的功能,get_meta_tags其中allo您是否需要解析網站源的元標記。

<?php 
// Assuming the above tags are at www.example.com 
$tags = get_meta_tags('http://www.example.com/'); 

// Notice how the keys are all lowercase now, and 
// how . was replaced by _ in the key. 
echo $tags['author'];  // name 
echo $tags['keywords'];  // php documentation 
echo $tags['description']; // a php manual 
echo $tags['geo_position']; // 49.33;-86.59 
?> 
+0

非常感謝你,這正是我需要的 – synan54 2013-04-22 08:34:00

相關問題