Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkPrice($url)
- {
- global $SKUS;
- global $amazonURLS;
- global $urls;
- $price = 0;
- if(strpos($url, 'homedepot.com') !== false) // Home Depot
- {
- $dom = file_get_html($url, false);
- $element = $dom->find('span#ajaxPrice.pReg',0);
- if(!isset($element))
- {
- $price = 0;
- return $price;
- }
- if(isset($element))
- {
- $price = $element->content;
- $price = strtok($price, "$"); //idk the best way to do this in PHP so lets do this
- $priceFloat = floatval($price);
- }
- }
- else if(strpos($url, 'amazon.com') !== false) //### Amazon, currently returning var_dump $DOM as NULL, some scraping protection?
- // Might have to try cURL library and set user agent with curl_setopt() and CURLOPT_USERAGEN
- // Follow redirects with CURLOPT_FOLLOWLOCATION -- Just an idea,
- {
- $dom = file_get_html($url, false);
- $element = $dom->find('span#newBuyBoxPrice.a-size-base',0);
- echo $element . "test";
- if(null === $element->content)
- {
- // echo "FAILED";
- $price = 0;
- return false;
- }
- if(null !== $element-content)
- {
- $price = $element->content;
- $price = strtok($price, "$");
- $priceFloat = floatval($price);
- }
- }
- return $priceFloat;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement