function price_book($book)
{
    global $SELLERS_URL;
    $best_book_price = 1000;
    $best_book_ship = 2.99;
    $best_book_ISBN = "";
    $best_book_url = NULL;
    $best_book_price_amazon = 0;
    // replace entites quote
    $book = str_replace("’", "'", $book);
    $book = urlencode($book);
    // 0. parse all books from pmba reading list
    foreach ($SELLERS_URL as $seller_url) {
        // 1. Parse all sellers and save best price + url
        $seller_price = price_book_sellers($seller_url, $book);
        if (isset($seller_price)) {
            $price = $seller_price[0];
            $url = $seller_price[1];
            // test best price
            if ($price < $best_book_price) {
                $best_book_price = $price;
                $best_book_url = $url;
            }
        }
    }
    // 2. from best book price url, get price, ship price, ISBN
    if (!isset($best_book_url)) {
        return;
    }
    $ISBN = get_ISBN($best_book_url);
    $best_book_price_amazon = get_amazon_price($book);
    return array($best_book_price_amazon, $best_book_price, $best_book_ship, $best_book_ISBN, $best_book_url);
}
function get_best_price($ISBN)
{
    $amazon_url = "http://www.amazon.fr/gp/offer-listing/" . $ISBN . "/sr=/qid=/ref=olp_tab_all?ie=UTF8&shipPromoFilter=0&coliid=&sort=sip&me=&qid=&sr=&seller=&colid=&condition=all";
    $html = connect_to($amazon_url);
    $html = str_get_html($html);
    // 0. First price is the cheapest one.
    $result = $html->find('.result', 0);
    $cheapest_price = $result->find('.price', 0)->plaintext;
    //1. Get the premium premium price
    $amazon_price = 0;
    $supersaver = $html->find('.supersaver', 0);
    if (isset($supersaver)) {
        $supersaver = $supersaver->parent();
        $amazon_price = $supersaver->find('.price', 0)->plaintext;
    } else {
        $amazon_price = get_amazon_price($ISBN);
    }
    $html->clear();
    unset($html);
    return array($amazon_price, $cheapest_price);
}