2

Is there any command line (CLI) implementation for Yahoo Query Language (YQL)?

A substitute for web-based YQL Console?

4
  • You can do it in your browser, with query.yahooapis.com/v1/public/yql?q={query} &format={format} Feb 18, 2015 at 9:14
  • This is interesting and quite detaield: openhacklondon.pbworks.com/f/… Feb 18, 2015 at 9:17
  • @Mawg Thanks, but web YQL Console is a bit slow for me, as I'm in need to test my own YQL tables and testing it on shell seems to be the fastest way.
    – kenorb
    Feb 18, 2015 at 10:21
  • @Mawg Thanks for the link, cURL+PHP example (from the slides) seems to be a good solution. But in example it won't use my custom YQL tables unless I'll published them.
    – kenorb
    Feb 18, 2015 at 10:31

1 Answer 1

1

I've found so far Interactive YQL build with Node.js (GitHub) which is based on old design by Diego Souza (called iyql package at Haskell package archive, see also sources at GitHub).

The old iyql package is similar to popular database frontend interfaces like sqlite3, but this project provides a full featured CLI for YQL.


However you don't need any external tool, as you can simply execute YQL queries from the command line using curl, in example:

curl -G --data-urlencode 'q=SELECT * FROM html WHERE url = "www.example.com" AND xpath="//p"' http://query.yahooapis.com/v1/public/yql

I've also created the following simple script (yql_query.sh):

#!/bin/bash
# Script to execute YQL query via Yahoo API from the command line.
# Usage: ./yql_query.sh query (format) (curl-args)
[ "$1" != "-" ] && query="$1" || query=$(cat -)   # Read query from 1st argument or stdin (-).
format=${2:-xml}                                  # Read format (default to xml).
url_api="http://query.yahooapis.com/v1/public/yql"
curl -G --data-urlencode "q=$query" "$url_api?format=$format" ${@:3}

Example usage:

$ ./yql_query.sh 'SELECT * FROM html WHERE url = "www.example.com"'
$ echo 'SELECT div FROM html WHERE url = "www.example.com"' | ./yql_query.sh - xml -v

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.