2009-11-28 65 views

回答

2

這裏是一種通過一個reg EXP做::鴨子::

$url = 'http://stackoverflow.com/questions/1811616/how-to-retrieve-the-title-part-of-other-web-page-like-google-or-yahoo-using-php'; 
preg_match('~<title>(.*?)</title>~i', file_get_contents($url), $match); 
echo $match[1]; 
1

你可以使用一些東西來獲取網頁的來源。 然後查找<title>子字符串的位置(將其稱爲start_index ...將7添加到它,因爲<title>是7個字符長))。還要查找</title>子字符串的位置(稱之爲end_index)。 該頁面的標題是start_index和end_index的子字符串。

相關問題