色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php根據isbn書號查詢amazon網站上的圖書信息的示例

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

復制代碼 代碼如下:
$isbn   = '007149216X';
$result = PIphp_GetBookFromISBN($isbn);
if (!$result) echo "Could not find title for ISBN '$isbn'.";
else echo "<img src='$result[1]' align='left'><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 name="description" 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);
}

php技術php根據isbn書號查詢amazon網站上的圖書信息的示例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 沅江市| 彝良县| 当雄县| 德安县| 临湘市| 周宁县| 通城县| 临西县| 达拉特旗| 宜春市| 赤水市| 海口市| 呼玛县| 河间市| 黎城县| 江川县| 东台市| 出国| 临高县| 彰武县| 彩票| 吉木乃县| 泸西县| 中牟县| 囊谦县| 昭通市| 甘泉县| 新竹县| 神池县| 赫章县| 修文县| 文登市| 新建县| 武功县| 蓬安县| 承德市| 达州市| 定州市| 长治市| 贞丰县| 清徐县|