php - Cannot load a specific URL with file_get_contents() -
i scraping http://www.beautyinzone.net/.
i using simple file_get_contents()
load url.
its working on localhost. not work when upload on live server.
warning: file_get_contents(http://www.beautyinzone.net/): failed open stream: connection timed out in script.php on line 36 page
if open other url works fine.
url
i have tried curl shows empty page, returns nothing.
one thought came in mind maybe blocked, should not that said website using servers.
what possible issue can preventing me loading url?
because remote server delaying reply you've re received http timeout error. it's normal.
tcp sockets has timeout set , when timeout reached timeout error raised. timeout 30 seconds (by default default_socket_timeout php.ini
setting used).
maybe want set (increase) custom timeout yourself:
<?php $http_context = stream_context_create(array( 'http' => array( 'timeout' => 60.0 # 60 seconds ) )); $url = 'http://www.beautyinzone.net'; $content = file_get_contents($url, false, $http_context);
via curl use:
curl_setopt($ch, curlopt_connecttimeout, 60);
Comments
Post a Comment