$form = send_request('http://maps.yandex.ru'); preg_match_all("/'secret-key':'(.+)'/Ui", $form, $matches); $key = $matches[1][0]; $result = send_request('http://maps.yandex.ru/?text=Органы+власти&where=&sll=30.31349700000001,59.93853099999101&sspn=1.0848999023437322,0.16951489115989204&source=catalog&key=' . $key . '&output=json'); var_dump($result); function send_request($url) { $headers = array( "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", "Accept: */*", "Accept-Language: en-US,en;q=0.8,ru;q=0.6", "Accept-Encoding: gzip, deflate,sdch", "Connection: keep-alive", ); $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_HEADER => 1, CURLOPT_HTTPHEADER => $headers, CURLOPT_RETURNTRANSFER => true, CURLOPT_VERBOSE => true, CURLOPT_ENCODING => "gzip", CURLOPT_COOKIESESSION => true, CURLOPT_COOKIEJAR => 'cookie.txt', CURLOPT_COOKIEFILE => 'cookie.txt' )); $output = curl_exec($ch); curl_close($ch); return $output; } |