Example of PHP searching for book information on Amazon's website based on ISBN ISBN

Source: Internet
Author: User
Tags strlen

  This article mainly introduces PHP according to the ISBN ISBN search for information on the Amazon website of the sample, the need for friends can refer to the following

Plugin Description: Based on the 10-bit ISBN, the plugin finds the details of the book on the Amazon website. If the result is found, an array of two elements is returned, where the first element is the title of the book, and the second element is the URL address of the book cover abbreviation. It requires the following parameters: $ISBN 10-bit ISBN ISBN     code as follows: $ISBN   = ' 007149216X '; $result = PIPHP_GETBOOKFROMISBN ($ISBN); if (! $result) echo "Could not find the 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    //  &nbsp //This plug-in looks up a ISBN-10 at Amazon.com and then    //returns the matching book title and a Thumbnai L Image    //of the front cover. It requires this argument:    //   //    $ISBN: The ISBN to look up    //   //Updated from the "function in the" 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);       $ptr 1 = strpos ($page, $find) + strlen ($find);    IF (! $ptr 1) return array (FALSE);       $PTR 2  = strpos ($page, '/> ', $ptr 1);     $title = substr ($page, $ptr 1, $ptr 2-$ptr 1);       $find = $img;     $PTR 1  = strpos ($page, $find) + strlen ($find);     $PTR 2  = strpos ($page, ' "', $ptr 1);     $image = substr ($page, $ptr 1, $ptr 2-$ptr 1);      return Array ($title, $img. $image); }    
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.