Advertisement
teslariu

formulario autom

Dec 21st, 2021
1,348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 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@gmail.com", "cursos": "Python"},
  8.     {"name":"Jose", "email":"ale@gmail.com", "cursos": "Python"},
  9.     {"name":"Ana", "email":"ale@gmail.com", "cursos": "Python"},
  10.     {"name":"Oscar", "email":"oscar@gmail.com", "cursos": "C++"},
  11.     {"name":"Tito", "email":"ale@gmail.com", "cursos": "Java"},
  12.     {"name":"Julieta", "email":"juli@gmail.com", "cursos": "Python"},
  13. ]
  14.  
  15. url = "http://localhost:8880/form"
  16.  
  17. for dato in datos:
  18.     r = requests.post(url, data=dato)
  19.     contenido = r.content.decode("utf-8")
  20.     if "correctamente" in contenido:
  21.         print(f"Datos del alumno {dato['name']} subidos correctamente")
  22.     else:
  23.         print(f"No se pudieron subir los datos del alumno {dato['name']}")
  24.         print(f"Error {r.status_code}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement