I would like to post string to Google search form and get a link of the first result. Now i have just easy script without any POST and using SimpleHtmlDom.
$arrContextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false
],
'http' => [
'method' => "GET",
'header' => "Accept-language: en\r\n" .
"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6\r\n".
"Cookie: foo=bar\r\n"
]
];
$html = HtmlDomParser::file_get_html("http://www.google.com/search?q=".urlencode($title), false, stream_context_create($arrContextOptions));
$link = $html->find("div[id=ires] div[class=g] h3[class=r] a",0)->href;
but the problem is, that format of this "href" is not in the right format, so i can´t use it. I tried to find some Google API for that, but was not successful.
How can i solve this problem?