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

A substitute for web-based YQL Console?


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):

# 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).
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
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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