You can download this code by clicking the button below.
This code is now available for download.
This code defines an asynchronous function to fetch random user information from https://randomuser.me/ API and prints it out.
Technology Stack : Aiohttp-web, Python asyncio
Code Type : Asynchronous HTTP request
Code Difficulty : Intermediate
import random
import aiohttp
import asyncio
async def fetch_random_user(session):
async with session.get('https://randomuser.me/api/') as response:
return await response.json()
async def main():
async with aiohttp.ClientSession() as session:
user_data = await fetch_random_user(session)
print(user_data)
# Code Information