teslariu

automatizar formulario

Oct 2nd, 2021
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. #  formu.py
  5. import requests
  6.  
  7. url = "http://localhost:8880/form"
  8.  
  9. datos = [
  10.     {'name':"Juan", "email":"juan@juan", "message":"Hola"},
  11.     {'name':"Ana", "email":"juan@juan", "message":"Hola"},
  12.     {'name':"Juana", "email":"juan@juan", "message":"Chau"},
  13.     {'name':"Fede", "email":"tito@juan", "message":"Hola"},
  14.     {'name':"Tito", "email":"juan@juan", "message":"Hola"},
  15. ]
  16.  
  17. for dato in datos:
  18.     r = requests.post(url, data=dato)
  19.     if "Mensaje enviado correctamente" in r.content.decode("utf-8"):
  20.         print(f"Mensaje del usuario {dato['name']} enviado correctamente")
  21.     else:
  22.         print(f"Mensaje del usuario {dato['name']} no enviado")
  23.  
Advertisement
Add Comment
Please, Sign In to add comment