サイトのソースを読み込もうとすると、次のようになることがあります (URL の例を示します)。
Warning: file_get_contents(http://www.iwantoneofthose.com/gift-novelty/golf-ball-finding-glasses/10602617.html)
[function.file-get-contents]: failed to open stream: HTTP request failed!
HTTP/1.1 500 Internal Server Error in /home/public_html/pages/scrape.html on line 165
それでも、URL 自体は問題ありません。なぜこのようなことが起こるのでしょうか?
次の回避策の提案を試しましたが、同じ結果になりました。
$opts = array('http'=>array('header' => "User-Agent:MyAgent/1.0\r\n"));
$context = stream_context_create($opts);
$header = file_get_contents('https://www.example.com',false,$context);
これは今私を困惑させています...