0

Hi i am trying to scrape some data on amazon but i always get blank result, i tried to change my useragent but it still does not work, please can someone look at what is wrong

<?php

require_once "core.php"; 

include "simple_html_dom.php";


$_curl = curl_init();
curl_setopt($_curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($_curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($_curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3');
curl_setopt($_curl, CURLOPT_URL, 'https://www.amazon.com/Apple-iPhone-Plus-Unlocked-32GB/dp/B01N6ZAR0D/');
$html = curl_exec( $_curl );

$_htmlDom = new simple_html_dom();
$_htmlDom->load(  $html  );

echo $html;

}

?>
Muhammad Faisal
  • 131
  • 1
  • 2
  • 8
  • 1
    "does not work" is not a helpful problem statement. _In what way_ does it not work? What _does_ happen? What do you expect to happen? What debugging have you done? – Patrick Q May 01 '19 at 18:42
  • i am trying to request amazon product page using php dom but i am getting this screen shots link : https://prnt.sc/nj7gkz , but if i change the link to aliexpress or ebay it loads fine – Muhammad Faisal May 01 '19 at 18:47
  • Do not switch `CURLOPT_SSL_VERIFYPEER` or `CURLOPT_SSL_VERIFYHOST` off. – Dharman May 01 '19 at 18:48
  • @Dharman still does not work – Muhammad Faisal May 01 '19 at 18:57
  • Have you got an up to date cert? What does [`curl_error()`](https://stackoverflow.com/a/3987037/1839439) tell you? – Dharman May 01 '19 at 18:59
  • @Dharman i am not getting any error, page load with weird text here is screenshot : https://prnt.sc/nj7gkz and if i change link to aliexpress or ebay it loads fine. – Muhammad Faisal May 01 '19 at 19:06
  • 1
    See here: https://stackoverflow.com/questions/53364974/getting-garbage-output-when-scraping-a-webpage-in-php – Patrick Q May 01 '19 at 19:07

0 Answers0