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: [ Ссылка ]
JSON: [ Ссылка ]
Code:
import requests
import json
import pprint
url = "[ Ссылка ]"
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: [ Ссылка ]
❤️❤️ 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.
❤️ [ Ссылка ]
LINKS
🗄️ GITHUB: [ Ссылка ]
💬 Follow me on Twitter: [ Ссылка ]
📜 Subscribe to my Newsletter: [ Ссылка ]
📝 Check out my Blog: [ Ссылка ]
⬇️ Download Geany Editor: [ Ссылка ]
LEARN MORE PYTHON
➡️Space Invaders: [ Ссылка ]
➡️Snake Game: [ Ссылка ]
➡️Pong: [ Ссылка ]
➡️Space War: [ Ссылка ]
➡️Intro to Python (for Java Coders): [ Ссылка ]
➡️Space Arena - The Ultimate Python Turtle Graphics Game Tutorial: [ Ссылка ]
LEARN MORE JAVA
➡️Basic Java for Beginners: [ Ссылка ]
➡️Intro to AP Computer Science A: [ Ссылка ]
#Python #Tutorial #API #JSON
Ещё видео!