国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 双鸭山市| 隆尧县| 天峨县| 盱眙县| 宁化县| 合川市| 隆安县| 棋牌| 宣化县| 鄂托克前旗| 宁化县| 罗江县| 叶城县| 裕民县| 友谊县| 江源县| 阿坝| 凤翔县| 抚州市| 大城县| 宜宾县| 葫芦岛市| 建始县| 青川县| 保靖县| 色达县| 台山市| 武山县| 庆云县| 株洲县| 怀远县| 邢台市| 柞水县| 江门市| 海口市| 桃园市| 永昌县| 常宁市| 扎兰屯市| 武义县| 闵行区|