国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > PHP > 正文

php根據(jù)isbn書號查詢amazon網(wǎng)站上的圖書信息的示例

2024-05-04 23:21:13
字體:
供稿:網(wǎng)友

插件說明:
插件根據(jù)提供的10位ISBN書號,在Amazon網(wǎng)站上查找該圖書的詳細(xì)信息。
如果找到結(jié)果,則返回一個兩元素的數(shù)組,其中第一個元素是書的標(biāo)題,而第二個元素是該書封面縮寫圖的URL地址。
它需要以下參數(shù):$ISBN 10位ISBN書號

復(fù)制代碼 代碼如下:


$isbn   = '007149216X';
$result = PIPHP_GetBookFromISBN($isbn);
if (!$result) echo "Could not find title for ISBN '$isbn'.";
else echo "<img src='$result[1]'><b>$result[0]";

function PIPHP_GetBookFromISBN($isbn)
{
   // Plug-in 93: Get Book From ISBN
   //
   // This plug-in looks up an ISBN-10 at Amazon.com and then
   // returns the matching book title and a thumbnail image
   // of the front cover. It requires this argument:
   //
   //    $isbn: The ISBN to look up
   //
   // Updated from the function in the book to take into
   // account changes to the Amazon HTML.

   $find = '<meta content="Amazon:';
   $url  = "http://www.amazon.com/gp/aw/d.html?a=$isbn";
   $img  = 'http://ecx.images-amazon.com/images/I';

   $page = @file_get_contents($url);
   if (!strlen($page)) return array(FALSE);

   $ptr1 = strpos($page, $find) + strlen($find);
   if (!$ptr1) return array(FALSE);

   $ptr2  = strpos($page, '" />', $ptr1);
   $title = substr($page, $ptr1, $ptr2 - $ptr1);

   $find = $img;
   $ptr1  = strpos($page, $find) + strlen($find);
   $ptr2  = strpos($page, '"', $ptr1);
   $image = substr($page, $ptr1, $ptr2 - $ptr1);

   return array($title, $img . $image);
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 嘉祥县| 元谋县| 临夏市| 高密市| 囊谦县| 岑巩县| 布拖县| 金秀| 琼中| 泽库县| 连州市| 郯城县| 温泉县| 罗山县| 天水市| 秀山| 德化县| 汽车| 名山县| 余庆县| 九龙坡区| 丰城市| 北京市| 剑河县| 澜沧| 谢通门县| 郴州市| 子洲县| 揭阳市| 永登县| 城口县| 延边| 辛集市| 崇义县| 交口县| 乌苏市| 新营市| 定安县| 和静县| 本溪市| 西安市|