Phillip Curry
Phillip Curry

Reputation: 9

python error - NameError:name download_url is not defined

I am trying to parse out the json response from a cURL command using a vendor's restful API. The full command is:

curl -s "url" -H "api" | python - c "import sys, json; print;(json.load(sys.stdin)["download_url"]);"

I keep getting an error that says NameError:name 'download_url' is not defined. Thoughts on how to fix this?

Upvotes: 0

Views: 872

Answers (1)

levi
levi

Reputation: 22697

Change " for ' in download_url. Using "download_url" you are closing first the ". Due that download_url is not longer belongs to python string command

curl -s "url" -H "api" | python - c "import sys, json; print;(json.load(sys.stdin)['download_url']);"

Upvotes: 2

Related Questions