How can I get the result of search in Google search, but without using the API.
I've tried many ways, but Google detects the ip server and prints an error. The function I use:
fopen
fsocket
...
For example this开发者_C百科 function can get html from other web sites, but for Google search, Google returns an error.
Is there a way I can get search results from Google?
function openpage($ur)
{
$buf="";
$ur=str_replace(" ","+",$ur);
$fp = fopen($ur, "rb");
if ($fp)
{
while(!feof($fp)) $buf=$buf.fgets($fp);
fclose($fp);
}
return $buf;
}
I have done a small project about it before. I used HTMLagilitypack.
Here is the source you can check it.
https://github.com/serdarb/Google-Results https://github.com/serdarb/Google-Results/blob/master/frmMain.cs
HtmlAgilityPack.HtmlNodeCollection hrefList = htmlDoc.DocumentNode.SelectNodes("//div//ol//li[@class='g']//h3//a");
But do not send to many requests... Google asks for a captcha or returns error.
精彩评论