Advertisement
teslariu

autom

Feb 5th, 2022
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. import requests
  5.  
  6. datos = [
  7.     {"name":"Alejandro", "email":"ale@email.com", "cursos": "Python"},
  8.     {"name":"Ana", "email":"ale@email.com", "cursos": "Python"},
  9.     {"name":"Victor", "email":"ale@email.com", "cursos": "Python"},
  10.     {"name":"Jose", "email":"ale@email.com", "cursos": "Python"},
  11.     {"name":"Vicky", "email":"ale@email.com", "cursos": "Python"},
  12.     {"name":"Ruben", "email":"ale@email.com", "cursos": "Python"},
  13.     {"name":"Luisa", "email":"ale@email.com", "cursos": "Python"},
  14.     {"name":"Alberto", "email":"ale@email.com", "cursos": "Python"},
  15.     ]
  16.  
  17. url = "http://localhost:8880/form"
  18.  
  19. for dato in datos:
  20.     r = requests.post(url, data=dato)
  21.     contenido = r.content.decode("utf-8")
  22.     if "correctamente" in contenido:
  23.         print(f"Datos del alumno {dato['name']} subidos correctamente")
  24.     else:
  25.         print(f"No se pudieron subir los datos del alumno {dato['name']}")
  26.         print(f"Código de respuesta {r.status_code}")
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement