Assuming file_get_contents makes an http request, it would be nice to check the specified user agent.
I heard about problems getting data with some user agents. Take a look at this question .
You can specify other parameters (including the user agent) using the stream context:
<?php $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" ) ); $context = stream_context_create($opts);
Take a look at the_get_contents docs file.
Also, as Jack said, cURL is the best option.
EDIT:
You're wrong. What you have to add is another user agent. For example, using a user agent from mozilla firefox, you get 4 results:
<?php $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; es-AR; rv:1.9.2.23) Gecko/20110921 Ubuntu/10.10 (maverick) Firefox/3.6.23" ) ); $context = stream_context_create($opts);
But, I think itβs not βlegalβ, itβs not good to cheat it. I think that there should be any other user agent that wikipedia provides to extract its data from external applications.
source share