Advertisement
teslariu

formu

Dec 11th, 2021
885
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Script para automatizar el envío masivo de datos a través de un
  5. # formulario
  6.  
  7. import requests
  8.  
  9. url = "http://localhost:8880/form"
  10.  
  11. datos = [
  12.     {"name":"Juan", "email":"jdsfuan@j.com", "message":"Python,C++"},
  13.     {"name":"Ana", "email":"juasdfn@j.com", "message":"Python,Java,C++"},
  14.     {"name":"Tito", "email":"juaryn@j.com", "message":"C++"},
  15.     {"name":"Leila", "email":"jfg@j.com", "message":"Python,Erlang"},
  16.     {"name":"John", "email":"rtert@j.com", "message":"Python,C++"},
  17.     {"name":"Astur", "email":"juan@j.com", "message":"Python,C++"},
  18. ]
  19. for dato in datos:
  20.     r = requests.post(url, data=dato)
  21.     if "correctamente" in r.content.decode("utf-8"):
  22.         print(f"Datos de {dato['name']} enviados correctamente")
  23.     else:
  24.         print(f"Error en el envío de los datos de {dato['name']}")
  25.         print(f"Error {r.status_code}")
  26.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement