How Can I Run a Local PHP Simple HTML DOM Parser with a Proxy?
Curl works whatever safe mode is enable or disable.Your Curl script is too complex, make it simple and try again.
$content = curl_exec_follow('http://www.supremenewyork.com/shop/new'); $html = new simple_html_dom();$html->load($content,true,false);
I modified your code, you can try.
// define cookie file path heredefine('CRAWLER_COOKIE_FILENAME', 'cookie.txt');function curl_exec_follow($url) { $proxy = '212.82.126.32:80'; $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1'; // Some websites check referrer $host = parse_url($url, PHP_URL_HOST); $scheme = parse_url($url, PHP_URL_SCHEME); $referrer = $scheme . '://' . $host; $ch = curl_init(); $curl_defaults = array( CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_RETURNTRANSFER => 1, ); curl_setopt_array($ch, $curl_defaults); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_USERAGENT, $agent); curl_setopt($ch, CURLOPT_REFERER, $referrer); if ( !file_exists(CRAWLER_COOKIE_FILENAME) || !is_writable(CRAWLER_COOKIE_FILENAME) ) { echo 'Cookie file is missing or not writable.'; exit; } curl_setopt($ch, CURLOPT_COOKIESESSION, 0); curl_setopt($ch, CURLOPT_COOKIEFILE, CRAWLER_COOKIE_FILENAME); curl_setopt($ch, CURLOPT_COOKIEJAR, CRAWLER_COOKIE_FILENAME); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // allow to crawl https webpages curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0); // the download speed must be at least 1 byte per second curl_setopt($ch,CURLOPT_LOW_SPEED_LIMIT, 1); // if the download speed is below 1 byte per second for more than 30 seconds curl will give up curl_setopt($ch,CURLOPT_LOW_SPEED_TIME, 30); $content = curl_exec($ch); if ($ret === FALSE) { echo curl_error($ch); } $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ( $code != '200' ) echo 'http error code: ' . $code; curl_close($ch); return $content;}