Good day. There was such a problem: when parsing, file_get_contents or curl_setopt do not accept the link from the array, there are many links in the file if you write like this (line 3):
$data = file('data.txt'); $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL, 'http://сайт/каталог/еще_что-нибудь.ру'); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($curl_handle); curl_close($curl_handle); then everything works, and if so, for example, or through a cycle:
$data = file('data.txt'); $curl_handle=curl_init(); curl_setopt($curl_handle, CURLOPT_URL, $data[1]); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($curl_handle); curl_close($curl_handle); then no, the links are absolutely the same, I tried it like this:
$context = stream_context_create([ 'http' => [ 'method' => 'GET', 'protocol_version' => '1.1', 'header' => [ 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0', 'Connection: close', ], ] ]); $stream = fopen('http://url', 'r', false, $context); $content = stream_get_contents($stream); $data = stream_get_meta_data($stream); the same, manually typed link works, from the array - no. What could be the problem?
curl_setopt($curl_handle, CURLOPT_URL, trim($data[1]));- Visman