Skip to content

Instantly share code, notes, and snippets.

@prodeveloper
Last active March 16, 2017 09:44
Show Gist options
  • Save prodeveloper/687f19073d19a65b00c1dc81ac42accf to your computer and use it in GitHub Desktop.
Save prodeveloper/687f19073d19a65b00c1dc81ac42accf to your computer and use it in GitHub Desktop.
Fetching post challenge

In this challenge we will be exercises our skills in:

  1. Using python libraries
  2. Using if constructs
  3. Using for construct
  4. Using methods

The requirement we need delivered is.

    As a reader, I want the system to ask me for the post ID that am interestd in and then fetch the post for me.

    As a reader, I want the system to return "None" if the post I requested is not available

You should fetch the posts from https://jsonplaceholder.typicode.com/posts

Hint:

  1. Use urllib to fetch the data
  2. Remember to decode the content from the website to utf-8 once fetched. By default urllib gives you content in bits, you want it in string before json decoding
  3. Use json library for decoding to a list
  4. Execute your search using for loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment