4

JavaScript を使用して YQL クエリの結果を表示する単純な html ファイルを設定するのが困難です。

YQL コンソールで select ステートメント (例: select title,abstract,url from search.web where query="pizza") をセットアップする方法を理解しています。しかし、htmlファイルに表示する方法がわかりませんか?

誰かがそのステートメントの結果を表示する方法を説明するのを手伝ってもらえますか? コード スニペットをいただければ幸いです。

ところで、私は YQL Docs を読みましたが、やや複雑です。

4

2 に答える 2

2

ここにあなたのための小さな例があります。YQL Web サイトを使用して作成しました。

<html>  
  <head>       
  </head>  
  <body>   
    <script>  
      function top_stories(o){ 
        // parse through the output here:
        var items = o.query.results.item;
        // do whatever you want with the output here:  
        console.log(items[0].title);
      }  
    </script> 
    <script src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D%22http%3A%2F%2Frss.news.yahoo.com%2Frss%2Ftopstories%22&format=json&diagnostics=false&callback=top_stories'></script>  
  </body>  
</html>

Yahoo! のフロント ページから最初のニュース記事を取得するだけです。

于 2016-08-07T00:17:12.047 に答える