запрос к гуглу через сокет

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<?php
echo "create\n";
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
echo "connect\n";
socket_connect($sock, 'ajax.googleapis.com', 80);
$http = "GET /uds/GwebSearch?v=1.0&rsz=large&hl=ru&start=1&q=news HTTP/1.1\r\nHost: ajax.googleapis.com\r\n\r\n";
echo "sending query\n";
socket_write($sock, $http);
echo "getting response\n";
do {
$response = socket_read($sock, 10000);
echo $response;
} while ($response!==false