首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google不返回结果

Google不返回结果
EN

Stack Overflow用户
提问于 2015-02-19 15:39:03
回答 1查看 380关注 0票数 0

我需要一个PHP Google搜索函数,所以我尝试了我在Google中找到的许多函数,但几乎所有函数都有相同的问题,它们直接从Google主URL获取结果,而不是从API URL获取结果,这会导致一段时间后出错,因为Google检测访问来自PHP服务器,并拒绝任何进一步的请求。

所以我让我的Google函数从Google中获取结果,就像您在这里看到的那样,URL非常有效,直到我需要减少结果购买--在搜索关键字之前添加intitle:,现在API根本不返回任何结果--就像您在这里看到的URL

我的问题很简单,如何使用这个查询intitle:maleficent+2014+site:www.anakbnet.com/video/file.php?f=在Google中获得结果,以便我可以使用PHP从中获取结果?

EN

回答 1

Stack Overflow用户

发布于 2015-02-19 16:02:01

您从“Google”调用中获得的数据是json编码的数据,因此您应该尝试如下所示:

代码语言:javascript
复制
    /* define a constant for ease */
    define('BR','<br />');


    $data='{"responseData": {"results":[{"GsearchResultClass":"GwebSearch","unescapedUrl":"http://www.anakbnet.com/video/file.php?f\u003d1452","url":"http://www.anakbnet.com/video/file.php%3Ff%3D1452","visibleUrl":"www.anakbnet.com","cacheUrl":"http://www.google.com/search?q\u003dcache:9-JgVUvjnGYJ:www.anakbnet.com","title":"مشاهدة فيلم Alexander and the Terrible اون لاين مباشرة بدون تحميل \u003cb\u003e...\u003c/b\u003e","titleNoFormatting":"مشاهدة فيلم Alexander and the Terrible اون لاين مباشرة بدون تحميل ...","content":"29 كانون الثاني (يناير) 2015 \u003cb\u003e...\u003c/b\u003e مشاهدة فيلم \u003cb\u003eMaleficent 2014\u003c/b\u003e DVD HD مترجم اون لاين مباشرة بدون تحميل اكشن ,مغامرة \n,عائلي .. مشاهدة افلام اجنبية مترجمة اونلاين كاملة. (مشاهدة: 491,605 )."}],"cursor":{"resultCount":"1","pages":[{"start":"0","label":1}],
     "estimatedResultCount":"1",
     "currentPageIndex":0,
     "moreResultsUrl":"http://www.google.com/search?oe\u003dutf8\u0026ie\u003dutf8\u0026source\u003duds\u0026start\u003d0\u0026hl\u003den-GB\u0026q\u003dmaleficent+2014+site:www.anakbnet.com/video/file.php?f%3D",
     "searchResultTime":"0.09"}}, 
     "responseDetails": null, 
     "responseStatus": 200}';



   $json=json_decode( $data, true );
   $res=(object)$json['responseData']['results'][0];

   /* two items extracted from data - use same methodology to get other items */
   echo $res->unescapedUrl;
   echo $res->cacheUrl;



    echo '<pre>';
    foreach( $json as $key => $param ){
        echo $key.BR;
        if( is_array( $param )) $param=(object)$param;  
        print_r( $param );
    }
    echo '</pre>';

希望你能从中找到你想要的?!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28610460

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档