Skip to content

Commit

Permalink
Issue pellcorp#67: Amazon ISBN13 search
Browse files Browse the repository at this point in the history
This adjusts the search to match what Amazon seems to return when searching
via ISBN13 UPC.
  • Loading branch information
utopiabound committed Sep 9, 2014
1 parent 729d599 commit e6aecba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/site/amazon.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ function queryListing($page_no, $items_per_page, $offset, $s_item_type, $search_
$amazonasin = trim($regs[1]);
} else if (preg_match("!<li><b>ISBN-10:</b>\s*([0-9]+)</li>!", $pageBuffer, $regs)) { // for books, ASIN is the same as ISBN
$amazonasin = trim($regs[1]);
} else if (preg_match_all("!<div id=\"result_[0-9]+\"[^>]*?name=\"([^\"])\"!", $pageBuffer, $regs)) {
if (count($regs[0]) == 1) {
$amazonasin = trim($regs[1]);
}
} else if (preg_match_all("!<div id=\"result_([0-9]+)\"!", $pageBuffer, $regs)) {
if (count($regs[0]) == 1) {
if (preg_match("!<a href=\".*?/dp/([^/]+)/.*?keywords=.*?!", $pageBuffer, $regs)) {
Expand All @@ -82,7 +86,9 @@ function queryListing($page_no, $items_per_page, $offset, $s_item_type, $search_

//<div class="resultCount">Showing 1 - 12 of 55 Results</div> || class="resultCount">Showing 1 Result</
//<span>1-24 von 194 Ergebnissen</span>
if ((preg_match("/ id=\"resultCount\">.*?<span>.*?.[0-9]+[\s]+?-[\s]+?[0-9]+.*?([0-9,]+).*?<\//", $pageBuffer, $regs) || preg_match("/ id=\"resultCount\">.*?<span>.*?.([0-9]+).*?<\//", $pageBuffer, $regs))) {
if ((preg_match("/ id=\"resultCount\">.*?<span>.*?.[0-9]+[\s]+?-[\s]+?[0-9]+.*?([0-9,]+).*?<\//", $pageBuffer, $regs) ||
preg_match("/ id=\"resultCount\">.*?<span>.*?.([0-9]+).*?<\//", $pageBuffer, $regs) ||
preg_match("/ id=.s-result-count.*?([0-9,]+) results for/", $pageBuffer, $regs) )) {
// need to remove the commas from the total
$total = str_replace(",", "", $regs[1]);

Expand Down

0 comments on commit e6aecba

Please sign in to comment.