Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- users = int(input("Introduce la cantidad de usuarios a buscar: "))
- counter = 1
- html = f"<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width, initial-scale=1.0'><title>Pagina web</title></head><body><h1>Bienvenido, usuario.</h1><br><h2>La cantidad de usuarios solicitada fueron: {str(users-1)}</h2>"
- f = open("pagina.html","w")
- f.write(html)
- f.close()
- while counter < users:
- req = requests.get("https://randomuser.me/api/?results="+str(users)).json()
- name = (req['results'][counter]['name']['first'])
- lname = (req['results'][counter]['name']['last'])
- pic = (req['results'][counter]['picture']['medium'])
- user_req = f"<p>Nombre: <strong>{name}</strong></p><p>Apellido: <strong>{lname}</strong></p><img src='{pic}' alt='img usuario'>"
- f = open("pagina.html","a")
- f.write(user_req)
- f.close()
- counter = counter+1
Add Comment
Please, Sign In to add comment