Рет қаралды 47,964
In this video I'll show you how to quickly and easily access web apis and convert the resulting JSON data into a Python dictionary, pull the relevant information out, and print it. We'll be using TV Maze to get information about various TV shows.
Links:
TV Maze API Info: www.tvmaze.com...
JSON: www.json.org/j...
Code:
import requests
import json
import pprint
url = "api.tvmaze.com/..."
show = input("Please input a show name. ")
params = {"q":show}
response = requests.get(url, params)
if response.status_code == 200:
data = json.loads(response.text)
pprint.pprint(data)
name = data['name']
premiered = data['premiered']
summary = data['summary']
print(f"{name} premiered on {premiered}.")
print(summary)
else:
print(f"Error: {response.status_code}")
NEED HELP?
🆘 Watch this first and then let me know in the comments below: • Help Me Help You
❤️❤️ SHOW SOME LOVE AND SUPPORT THE CHANNEL ❤️❤️
Click Join and Become a Channel Member Today!
Channel members can get preferential comment replies, early access to new content, members only live streams, and access to my private Discord.
❤️ / @tokyoedtech
LINKS
🗄️ GITHUB: github.com/wyn...
💬 Follow me on Twitter: / tokyoedtech
📜 Subscribe to my Newsletter: eepurl.com/dKgM8k
📝 Check out my Blog: christianthomp...
⬇️ Download Geany Editor: www.geany.org
LEARN MORE PYTHON
➡️Space Invaders: • Python Game Programmin...
➡️Snake Game: • Python Game Programmin...
➡️Pong: • Python Game Programmin...
➡️Space War: • Python Game Programmin...
➡️Intro to Python (for Java Coders): • Intro to Python for Ja...
➡️Space Arena - The Ultimate Python Turtle Graphics Game Tutorial: • Ultimate Python Turtle...
LEARN MORE JAVA
➡️Basic Java for Beginners: • Basic Java 1&2: Commen...
➡️Intro to AP Computer Science A: • AP Computer Science Un...
#Python #Tutorial #API #JSON