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} Commented Feb 18, 2015 at 9:14
  • This is interesting and quite detaield: openhacklondon.pbworks.com/f/… Commented 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. Commented 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. Commented 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.