Example of php querying book information on amazon Website Based on isbn

Source: Internet
Author: User
This article describes how to use php to query the book information on the amazon Website Based on the isbn number. For more information, see

This article describes how to use php to query the book information on the amazon Website Based on the isbn number. For more information, see

Plugin description:
Based on the provided ten-digit ISBN book number, the plug-in searches for detailed information about the book on the Amazon website.
If the result is found, an array of two elements is returned. The first element is the title of the book, and the second element is the URL address of the album art abbreviation.
It requires the following parameters: $ ISBN 10-bit ISBN Book Number

The Code is as follows:


$ Isbn = '007149216x ';
$ Result = PIPHP_GetBookFromISBN ($ isbn );
If (! $ Result) echo "cocould 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
// 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 );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.