Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Нужна помощь с cUrl. (Examining connection #0 for reuse) / 3 сообщений из 3, страница 1 из 1
22.05.2012, 19:36:35
    #37806591
LcF
LcF
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Нужна помощь с cUrl. (Examining connection #0 for reuse)
Вечер добрый, форумчане!
Подскажите пожалуйста по cUrl.
есть код
...
Рейтинг: 0 / 0
22.05.2012, 19:43:39
    #37806600
LcF
LcF
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Нужна помощь с cUrl. (Examining connection #0 for reuse)
Извиняюсь за отправку прошлого сообщения.
есть код
+
Код: php
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
$hostname = 'https://vot***.***contact.ru/common/aaa/authorization.php?refadr=/mser/Outbound/sc110209_0000_migcredit_outbound_5/internal/voiceunloader.php';
$hostname2 = 'https://vot***.***econtact.ru/mser/Outbound/sc110209_0000_migcredit_outbound_5/internal/voiceunloader.php';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $hostname);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'user_nickname=123&user_password=123');
curl_setopt($ch, CURLOPT_USERAGENT, "Opera/10.00 (Windows NT 5.1; U; ru) Presto/2.2.0");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // не проверять SSL сертификат
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // не проверять Host SSL сертификата
curl_setopt($ch, CURLOPT_MAXREDIRS, 10000);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 100); // разрешаем редиректы
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); // разрешаем редиректы
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Transfer-Encoding: ', 'Expect:')); 

$data = curl_exec($ch);

curl_setopt($ch, CURLOPT_URL, $hostname2);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'df_start_day=3&df_start_month=5&df_start_year=2011&df_start_hour=0&df_start_minute=0&df_end_minute=59&df_end_hour=23&df_end_year=2011&df_end_month=5&df_end_day=4&fl=all&filterCompnum=&filterPhone=&filterContactId=&filterDurationFrom=&filterDurationTo=&filterResult=&filterOperator=&filterAgentNumber=&filterFolderName=&submit=test');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); 

$data = curl_exec($ch);

preg_match_all("%<a[^>]*>Голосовые файлы удаленно</a>%im", $data, $hrefs);

$j = 0;
foreach ($hrefs as $key => $value) {
    foreach ($value as $key2 => $value2) {
        preg_match_all("#window.open\([\"'](.*?)[\"',>\)]#is", $value2, $ok);
        $remotely[$j] = $ok[1][0];
        $j++;
    }
}

$f = fopen('1.txt', 'ab');

for ($i = 0; $i<count($remotely);$i++) {    
     fwrite($f, $i);
     fwrite($f, "      ");
      fwrite($f, $remotely[$i]);
      
      curl_setopt($ch, CURLOPT_URL, $remotely[$i]);
      curl_setopt($ch, CURLOPT_FAILONERROR, true);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); 
      curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); // разрешаем редиректы
      curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_VERBOSE, true); 
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); 
      curl_setopt($ch, CURLOPT_STDERR, $f);
      curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); // set where cookies will be stored
      curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); //

      $data = curl_exec($ch);

      echo $data;

      fwrite($f, "--------------------------------------------------------------------");
}
fclose($f); 
curl_close($ch);



Так вот, на последнем цикле, при обходе полученных ранее ссылок, через cUrl удается получить только половину из них. На вторую половину в лог пишется
+
Код: php
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
0      https://vot***.***econtact.ru/sav/www/VocalFileProxy/proxy.php?https://vote3.telecontact.ru/sav/Core0/filesearch.php?calldatestart=2011-05-03 09:57:11&calldateoffset=240&callpartyorig=390284&callpartydest=1413303
* Examining connection #0 for reuse
* Re-using existing connection! (#0) with host vot***.***econtact.ru
* Connected to vot***.***econtact.ru (78.40.26.88) port 443 (#0)
> POST /sav/www/VocalFileProxy/proxy.php?https://vote3.telecontact.ru/sav/Core0/filesearch.php?calldatestart=2011-05-03 09:57:11&calldateoffset=240&callpartyorig=390284&callpartydest=1413303 HTTP/1.1
User-Agent: Opera/10.00 (Windows NT 5.1; U; ru) Presto/2.2.0
Host: vot***.***econtact.ru
Accept: */*
Cookie: CallSearcher=b0e619fe14a1c90a838762cc61e5fa47; PHPSESSID=6a8932f2691b085df4a9fa4b3ad7cabb; aaasession=d14929359e7236426d5b817d15f4bee1
Content-Length: 330
Content-Type: application/x-www-form-urlencoded

* The requested URL returned error: 400



Как это можно исправить? С cUrl не знаком вообще - все это писал по тому что нарыл в инете.
Заранее благодарен за ответ
...
Рейтинг: 0 / 0
22.05.2012, 21:58:59
    #37806785
vkle
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Нужна помощь с cUrl. (Examining connection #0 for reuse)
400 Bad Request — сервер обнаружил в запросе клиента синтаксическую ошибку.
В строке запроса непотребное, видимо. Попробуйте прогнать ее через urlencode() перед отправкой.
...
Рейтинг: 0 / 0
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Нужна помощь с cUrl. (Examining connection #0 for reuse) / 3 сообщений из 3, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]