JavaScript的API - 如何做到这一点的PHP(用于谷歌新闻) [英] JavaScript API - how to do it in PHP (for Google News)
问题描述
谷歌新闻有API,如下所述:
HTTP://$c$c.google.com/apis/newssearch /v1/index.html
Google News has API, described here: http://code.google.com/apis/newssearch/v1/index.html
但它是一个JavaScript API(客户端)。我想运行谷歌新闻搜索每天一次为一个固定词组,自动,一台服务器上,并将结果纳入我的数据库(服务器端,使用PHP)。
But it is a JavaScript API (client side). I would like to run Google News search once a day for a fixed phrase, automatically, on a server and integrate the results into my database (server side, using PHP).
任何人都可以建议如何解决这个问题,我的意思是在谷歌API的一面呢?我做了使用PHP simple_html_dom类,它是解析HTML原料和提取,如新闻标题,正文等元素但现在我觉得它不是一个专业的解决方案,因为如果谷歌自己的HTML结构内改变任何东西的解决方案,我的code将中断。
Could anyone suggest how to deal with this, I mean on Google API side? I made a solution using PHP simple_html_dom class, which is parsing raw html and extracting elements like news title, body etc. But now I think it is not a professional solution, because if Google changes anything within the structure of their html, my code will break.
因此,也许有一个小窍门,如何在PHP中使用JavaScript API?
So maybe there is a trick, how to use a JavaScript API in PHP?
推荐答案
有一个在PHP的例子为谷歌新闻搜索API。
Have a look at the PHP example for Google News Search API.
HTTP://$c$c.google。 COM /的API /新闻搜索/ V1 / jsondevguide.html#json_snippets_php
这篇关于JavaScript的API - 如何做到这一点的PHP(用于谷歌新闻)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!