Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   помогите эмулировать работу браузера (https://forum.antichat.xyz/showthread.php?t=80813)

FaR-G9 14.08.2008 04:59

помогите эмулировать работу браузера
 
сабж

вот я написал такой скрипт
PHP код:

$fp fsockopen(‘www.host.ru’80$errno$errstr30);
if (!
$fp) {

   echo 
‘Unable to open\n’;

} else {
$out ‘GET /onlinestats HTTP/1.0\r\n’;
$out .= ‘X-Requested-WithXMLHttpRequest\r\n’;
$out .= ‘X-Prototype-Version1.5.0_rc0\r\n\r\n’;
$out .= ‘Accepttext/javascripttext/htmlapplication/xmltext/xml, */*, text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\n\r\n’;
$out .= ‘User-AgentOpera/9.51 (Windows NT 6.0Uru)\r\n\r\n’;
$out .= ‘Hosthost.ru\r\n\r\n’;
$out .= ‘Accept-Languageru-RU,ru;q=0.9,en;q=0.8\r\n\r\n’;
$out .= ‘Accept-Charsetiso-8859-1utf-8utf-16, *;q=0.1\r\n\r\n’;
$out .= ‘Accept-Encodinggzipdeflate\r\n\r\n’;
$out .= ‘Refererhttp://antichat.ru\r\n\r\n’;
$out .= ‘Cookie: \r\n\r\n’;
$out .= ‘Cookie2: \r\n\r\n’;
$out .= ‘Connectionkeep-alive\r\n\r\n’;

fwrite($fp$out);
while (!
feof($fp)) {
echo 
fgets($fp128);
}
fclose($fp);



в ответ мне сервер присылает пакет

Код:

HTTP/1.0 200 OK
Server: nginx/0.7.3
Date: Thu, 14 Aug 2008 00:41:11 GMT
Content-Type: text/xml; charset=UTF-8
Connection: keep-alive
Keep-Alive: timeout=20
Set-Cookie: xsid=f503575c37c760305811eda0829d58e1; domain=.host.ru; path=/; expires=Sun, 12-Aug-2018 00:41:11 GMT
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 2862

как можно значение кукиса из ответа(xsid=f503575c37c760305811eda0829d58e1 ;)
присвоить переменной?

Vid0k 14.08.2008 05:19

типа того
PHP код:

preg_match_all("/xsid=([0-9a-z]{32})/",$otvet,$massiv);
print_r($massiv); 

не проверял

Vid0k 14.08.2008 05:21

и убери строчку
Цитата:

Accept-Encoding: gzip, deflaternrn
а то у тя ответ весь в гзипе будет идти кроме заголовков


Время: 20:01