помогите эмулировать работу браузера
сабж
вот я написал такой скрипт
PHP код:
$fp = fsockopen(‘www.host.ru’, 80, $errno, $errstr, 30);
if (!$fp) {
echo ‘Unable to open\n’;
} else {
$out = ‘GET /onlinestats HTTP/1.0\r\n’;
$out .= ‘X-Requested-With: XMLHttpRequest\r\n’;
$out .= ‘X-Prototype-Version: 1.5.0_rc0\r\n\r\n’;
$out .= ‘Accept: text/javascript, text/html, application/xml, text/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-Agent: Opera/9.51 (Windows NT 6.0; U; ru)\r\n\r\n’;
$out .= ‘Host: host.ru\r\n\r\n’;
$out .= ‘Accept-Language: ru-RU,ru;q=0.9,en;q=0.8\r\n\r\n’;
$out .= ‘Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1\r\n\r\n’;
$out .= ‘Accept-Encoding: gzip, deflate\r\n\r\n’;
$out .= ‘Referer: http://antichat.ru\r\n\r\n’;
$out .= ‘Cookie: \r\n\r\n’;
$out .= ‘Cookie2: \r\n\r\n’;
$out .= ‘Connection: keep-alive\r\n\r\n’;
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
}
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 ;)
присвоить переменной?
|