I'm having some issues getting PHP Simple HTML DOM Parser to work with a proxy. I read the info they have on the procedure in the manual but it still isn't cooperating.
require_once('simple_html_dom.php');
$url = 'http://www.whatsmyip.org/';
$proxy = '00.000.000.80:80';
$context = array(
'http' => array(
'proxy' => $proxy,
'request_fulluri' => true,
),
);
$context = stream_context_create($context);
$dom = new simple_html_dom();
$dom = file_get_html($url, false, $context);
echo '<pre>';
print_r($dom);
echo '</pre>';
I only changed some parts, but clearly, the proxy example you provided it isn't working. Try this instead:
$context = array('http' => array('proxy' => 'tcp://221.176.14.72:80','request_fulluri' => true,),);
$stream = stream_context_create($context);
$dom = file_get_html('http://www.whatsmyip.org/', false, $stream);
$ip = $dom->find('span#ip', 0)->innertext;
echo $ip;
I managed to get it working using cURL to feed the page into PHP Simple HTML dom parser.
require_once('simple_html_dom.php');
$url = 'http://www.whatsmyip.org/';
$proxy = '00.000.000.80:80';
$options = array(
CURLOPT_PROXY => $proxy,
CURLOPT_HTTPPROXYTUNNEL => 0,
CURLOPT_REFERER => "http://www.google.com",
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1",
CURLOPT_CONNECTTIMEOUT => 20,
CURLOPT_TIMEOUT => 20,
CURLOPT_MAXREDIRS => 10,
CURLOPT_HEADER => true,
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$dom = new simple_html_dom();
$dom->load($content,true,false);
echo '<pre>';
print_r($dom);
echo '</pre>';