Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Getting only the link variable from the JSON string #3

Open
Aschinea opened this issue Aug 22, 2020 · 1 comment
Open

[Question] Getting only the link variable from the JSON string #3

Aschinea opened this issue Aug 22, 2020 · 1 comment

Comments

@Aschinea
Copy link

Aschinea commented Aug 22, 2020

Hello,

I'm using this wrapper for a very simple purpose, getting a link of a certain gif (and quite possibly other peices of information, but just by knowing how to get a variable I can figure it out).

This is my code, and working perfectly until the part where getting the variable. I know I'm doing something wrong, but don't really know how to fix it:

search = input('Tell me a word or phrase for me to search: ')

q = search
limit = 1
lang = 'en'
fmt = 'json'
api_response = api_instance.gifs_search_get(api_key, q, limit=limit, lang=lang, fmt=fmt)
pprint(api_response)
jsonstring=json.loads(api_response)
pairs = jsonstring.items()

for key, url in pairs:

    print(url)

I'm still learning how to use json (or dict strings) and how to use them, so any help appreciated!

@af-inet

@Aschinea Aschinea changed the title Getting only the link variable from the JSON string [Question] Getting only the link variable from the JSON string Aug 22, 2020
@zschumacher
Copy link

you might be interested in checking out my package https://github.com/zschumacher/giphpy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants