Snippets

Dénes Türei Download and process JSON in bash

Created by Dénes Türei
#!/usr/bin/env bash

# Denes Turei 2018
# turei.denes@gmail.com

url="`printf %s \
    'http://mdl.shsmu.edu.cn/ASD/SphnixFullTextSearch'\
    '?_dc=1527513083983&keyword=%s&max_matches=1000&'\
    'page=1&start=0&limit=20'`"

search='ASD02170001'

process="$(cat << EOF
import sys
import json

data = json.loads(sys.stdin.read())

sys.stdout.write('Names: %s\\n' % ', '.join(
    e['entity_name'] for e in data['data']
))

EOF
)"

curl -L `printf $url $search` | python -c "$process"

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.