我想在 PHP 中创建一个类似于 YQL 的 API,用户可以在其中运行查询来获取数据。任何机构都可以指导我如何实现这一目标吗?我们可以从一个非常基本的查询开始。只需要指导如何在 PHP 和 MYsql 中实现这一点?
问问题
214 次
1 回答
-1
我在此处复制并粘贴了此内容,以便您更好地理解,并且那些将查看它的人将其作为您问题的示例方法。
这是 mysql 之类的 yql 命令
**
select * from html where url="http://finance.yahoo.com/q?s=yhoo" and
xpath='//div[@id="yfi_headlines"]/div[2]/ul/li/a'
**
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="15" yahoo:created="2016-01-11T17:09:07Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="1" execution-stop-time="1228" execution-time="1227"><![CDATA[http://finance.yahoo.com/q?s=yhoo]]></url>
<url execution-start-time="1" execution-stop-time="1228" execution-time="1227"><![CDATA[http://finance.yahoo.com/q?s=yhoo]]></url>
<user-time>1231</user-time>
<service-time>2445</service-time>
<build-version>0.2.369</build-version>
</diagnostics>
<results>
<a data-ylk="cp:American City Business Journals;o:e;" href="http://us.rd.yahoo.com/finance/external/bizj/SIG=139c9j4lb/*http://www.bizjournals.com/sanjose/news/2016/01/11/yahoo-staff-are-losing-faith-in-the-company-and.html?ana=yahoo">Yahoo staff are losing faith in the company and its leadership</a>
<a data-ylk="cp:Zacks;o:i;" href="http://finance.yahoo.com/news/technology-stock-roundup-dismal-start-150703080.html">Technology Stock Roundup: Dismal Start to 2016</a>
<a data-ylk="cp:Forbes;o:e;" href="http://us.rd.yahoo.com/finance/external/forbes/SIG=14082so2n/*http://www.forbes.com/sites/ericjackson/2016/01/11/want-an-instant-2-5-million-bonus-at-yahoo-allegedly-just-threaten-to-quit/?utm_campaign=yahootix&partner=yahootix">Want An Instant $2.5 Million Bonus At Yahoo? Allegedly, Just Threaten To Quit</a>
<a data-ylk="cp:Barrons.com;o:e;" href="http://us.rd.yahoo.com/finance/external/barrons/SIG=13cgi999q/*http://blogs.barrons.com/techtraderdaily/2016/01/11/yahoo-talk-of-core-sale-in-focus-again-on-nyt-article/?mod=yahoobarrons&ru=yahoo">Yahoo! Talk of 'Core' Sale in Focus Again on NYT Article</a>
<a data-ylk="cp:Insider Monkey;o:e;" href="http://us.rd.yahoo.com/finance/external/xinsidermonkey/SIG=14d3lit34/*http://www.insidermonkey.com/blog/a-look-at-whitebox-advisors-top-equity-holdings-as-it-prepares-to-close-down-its-mutual-fund-unit-405548/">A Look At Whitebox Advisors Top Equity Holdings As It Prepares To Close Down Its Mutual Fund Unit</a>
<a data-ylk="cp:Bloomberg;o:i;" href="http://finance.yahoo.com/video/yahoo-said-reconsider-business-sale-142447099.html">Yahoo Said to Reconsider Web Business Sale, Why?</a>
<a data-ylk="cp:Bloomberg;o:e;" href="http://us.rd.yahoo.com/finance/external/bloomberg/SIG=131lr1djm/*http://www.bloomberg.com/news/videos/2016-01-11/yahoo-said-to-reconsider-web-business-sale-why-?cmpid=yhoo.headline">Yahoo Said to Reconsider Web Business Sale, Why?</a>
<a data-ylk="cp:CNBC;o:i;" href="http://finance.yahoo.com/video/twitter-shares-down-48-past-134500309.html">Twitter shares down 48% in past year</a>
<a data-ylk="cp:CNBC;o:e;" href="http://us.rd.yahoo.com/finance/external/cnbc/SIG=112isi8k7/*http://www.cnbc.com/id/103294156?__source=yahoo%7cfinance%7cheadline%7cheadline%7cstory&par=yahoo&doc=103294156">Early movers: BXLT, AEO, HSY, M, APOL, WSM & more</a>
<a data-ylk="cp:Benzinga;o:i;" href="http://finance.yahoo.com/news/bob-peck-yahoo-separation-bulk-123554615.html">Bob Peck On Yahoo: Separation Is Bulk Of Value</a>
<a data-ylk="cp:Fox Business Video;o:i;" href="http://finance.yahoo.com/video/time-marissa-mayer-yahoo-ceo-120443101.html">Time for Marissa Mayer to go as Yahoo CEO?</a>
<a data-ylk="cp:The Wall Street Journal;o:e;" href="http://us.rd.yahoo.com/finance/external/wsj/SIG=134mdgf4d/*http://www.wsj.com/articles/cmo-today-apple-news-falls-short-of-publishers-expectations-1452513606?mod=yahoo_hs">CMO Today: Apple News Falls Short of Publishers' Expectations</a>
<a data-ylk="cp:Quartz;o:i;" href="http://us.rd.yahoo.com/finance/external/quartz/SIG=12kug5d3h/*http://qz.com/590363/yahoos-plan-a-b-c-d-and-e-for-appeasing-frustrated-investors/?utm_source=YPL">Yahoo’s plan A, B, C, D, and E for appeasing frustrated investors</a>
<a data-ylk="cp:Bloomberg;o:e;" href="http://us.rd.yahoo.com/finance/external/bloomberg/SIG=136qrbvv6/*http://www.bloomberg.com/news/videos/2016-01-09/yahoo-s-web-business-bloomberg-west-full-show-01-08-?cmpid=yhoo.headline">Yahoo's Web Business: Bloomberg West (Full Show 01/08)</a>
<a data-ylk="cp:Bloomberg;o:i;" href="http://finance.yahoo.com/video/yahoo-considering-sale-core-biz-234206699.html">Yahoo Considering Sale of Core Biz After Activists’ Push</a>
</results>
</query>
访问此链接以获得更好的理解。
于 2016-01-11T17:15:57.100 回答