Answer the question
In order to leave comments, you need to log in
RSS - opens without problems in the browser, but does not load through PHP in any way. Why?
Good afternoon Toaster!
I've already broken my head, honestly. I have already encountered problems with accessing sites through PHP, but this has always been solved, but this time it didn’t. I am turning to you for help.
This address quite calmly comes off in the browser, giving RSS:
zakupki.gov.ru/epz/order/quicksearch/rss?searchStr...
But neither through file_get_contents(), nor through cURL, with a variety of combinations of settings, I can get it I can not.
file_get_contents example:
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'protocol_version' => '1.1',
'header' => array(
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0',
)
)
));
$r = file_get_contents($url, false, $context);
debug($r);
debug($http_response_header);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_REFERER, 'http://zakupki.gov.ru/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0');
curl_setopt($ch, CURLOPT_URL, $o['url']);
Answer the question
In order to leave comments, you need to log in
Your first example with file_get_contents worked fine.
Probably a lot of requests were made, added to the ban or cached on the proxy?
It worked for me like this:
$url = "http://zakupki.gov.ru/epz/order/quicksearch/rss?searchString=&morphology=on&pageNumber=1&sortDirection=false&recordsPerPage=_10&showLotsInfoHidden=false&fz44=on&fz223=on&af=on®ions=&priceFrom=0&priceTo=200000000000¤cyId=1&publishDateFrom=16.06.2016&publishDateTo=16.06.2016&updateDateFrom=&updateDateTo=&sortBy=PRICE";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:47.0) Gecko/20100101 Firefox/47.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_HEADER, 0);
$exec=curl_exec ($ch);
echo($exec);
This code is working (I checked it myself). Result: prntscr.com/bh7uvu
$context = stream_context_create(array(
'http' => array(
'method' => 'GET',
'protocol_version' => '1.1',
'header' => array(
'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0',
)
)
));
$r = file_get_contents($url, false, $context);
var_dump($r);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question