国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 昔阳县| 湘潭县| 正安县| 天祝| 云林县| 怀来县| 铁岭市| 达孜县| 永年县| 宁津县| 马山县| 兴文县| 恭城| 宝鸡市| 青海省| 阳春市| 富民县| 建阳市| 云霄县| 武鸣县| 印江| 南康市| 富宁县| 石柱| 徐水县| 诸暨市| 资中县| 久治县| 克什克腾旗| 五原县| 古田县| 土默特左旗| 安龙县| 仁怀市| 唐河县| 张家口市| 阳东县| 宣汉县| 遂宁市| 黎平县| 定安县|