Is there any command line (CLI) implementation for Yahoo Query Language (YQL)?
A substitute for web-based YQL Console?
Software Recommendations Stack Exchange is a question and answer site for people seeking specific software recommendations. It only takes a minute to sign up.
Sign up to join this communityIs 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):
#!/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