I am crawling a website using following code
require 'simple_html_dom.php';
$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0
"));
$context = stream_context_create($opts);
$header = file_get_contents('http://www.cinnetwork.org',false,$context);
print_r($header);
This code works correctly in phpfiddle. But when i use it from my server it says
Warning: file_get_contents(http://www.cinnetwork.org): failed to open stream: Connection timed out
I also tried using curl. It also shows the similar error.
$url= 'https://example.com';
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$response = file_get_contents($url, false, stream_context_create($arrContextOptions));
A suggestion, you can use CURL instead ..