Subversion Repositories cheapmusic

Rev

Rev 91 | Rev 95 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 91 Rev 93
Line 28... Line 28...
28
        $dom = new DOMDocument;
28
        $dom = new DOMDocument;
29
        $dom->loadHTML($html);
29
        $dom->loadHTML($html);
30
        $xpath = new DOMXPath($dom);
30
        $xpath = new DOMXPath($dom);
31
 
31
 
32
        $nodes = $xpath->query('//table[@id="productDetailsTable"]//ul/li');
32
        $nodes = $xpath->query('//table[@id="productDetailsTable"]//ul/li');
33
        if ($nodes->length < 1 || ++$productCnt > 5) {
33
        if ($nodes->length < 1 || ++$productCnt > 5) { // bugbug
34
            continue;
34
            continue;
35
        }
35
        }
36
        $str = trim($nodes->item(0)->nodeValue);
36
        $str = trim($nodes->item(0)->nodeValue);
37
        $p = strpos($str, " (");
37
        $p = strpos($str, " (");
38
        $format = ($p > 0 ? substr($str, 0, $p) : $str);
38
        $format = ($p > 0 ? substr($str, 0, $p) : $str);
Line 190... Line 190...
190
        }
190
        }
191
 
191
 
192
    }
192
    }
193
 
193
 
194
    return ($arr);
194
    return ($arr);
-
 
195
}
-
 
196
 
-
 
197
function addMatch_scrape($query, $searchCondition) {
-
 
198
// $needMatches
-
 
199
    $products = [];
-
 
200
 
-
 
201
    libxml_use_internal_errors(true);
-
 
202
    $html = getUrl("https://www.amazon.com/s?k=" . rawurlencode($query) . "&sf=qz&i=popular&unfiltered=1&ref=nb_sb_noss");
-
 
203
    $dom = new DOMDocument;
-
 
204
    $dom->loadHTML($html);
-
 
205
    $xpath = new DOMXPath($dom);
-
 
206
    $nodes = $xpath->query('//a/@href');
-
 
207
    foreach($nodes as $href) {
-
 
208
        if (strpos($href->nodeValue, "/dp/B") > 0) {
-
 
209
            $products[] = $href->nodeValue;
-
 
210
        }
-
 
211
    }
195
}
212
}