php根據isbn書號查詢amazon網站上的圖書資訊的樣本_PHP教程

來源:互聯網
上載者:User
外掛程式說明:
外掛程式根據提供的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 "$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 = ' $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);
}

http://www.bkjia.com/PHPjc/735234.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/735234.htmlTechArticle外掛程式說明: 外掛程式根據提供的10位ISBN書號,在Amazon網站上尋找該圖書的詳細資料。 如果找到結果,則返回一個兩元素的數組,其中第一個元...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.