Hola
Propósito:
1-n para producir correos electrónicos
2-n para generar contraseñas
3- Para crear n miembros en total.
Sólo estoy aprendiendo a codificar pitones. Quiero hacer un nuevo proyecto basado en el proyecto a continuación.
pero no tuve éxito
Siento lo de mi español. traducción de Google. :)
import requests
import random
from random import getrandbits
import time
session = requests.session()
url = 'https://www.trendyol.com/login'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36'}
email = 'test+{}@gmail.com'.format(getrandbits(40)) #enter your email, dont change anything after '+'
password = 'Testing1234' #enter your password, minimum 8 characters
times = int(input("[" + (time.strftime("%H:%M:%S") + "]" + " - Enter the number of account(s) you would like to create: ")))
text_file = open("chmielna accounts.txt", "w")
def create_account():
print("[" + (time.strftime("%H:%M:%S")) + "]" + " - SUBMITTING INFO.....")
global session
global email
payload = {
"RegisterModel_Email": email,
"RegisterModel_Password": password,
"newTermsOfUse": "on"
}
def write():
text_file.write(email + ":" + password + "\n")
if "Success" in response.text:
print("[" + (time.strftime("%H:%M:%S")) + "]" +" - SUCCESSFULLY CREATED ACCOUNT "+email+":"+password)
write()
else:
print("[" + (time.strftime("%H:%M:%S")) + "]" +" - ERROR COULD NOT CREATE "+email+":"+password)
for i in range (times):
create_account()
La respuesta del código es la siguiente. No es inoperante.
(https://snipboard.io/VorGdF.jpg)
HI @rfve (https://underc0de.org/foro/index.php?action=profile;u=111043),
As with this question https://underc0de.org/foro/dudas-generales-121/ayuda-script-python/ (https://underc0de.org/foro/dudas-generales-121/ayuda-script-python/) the problem is that the code is making no request at all, it is just defining the variables, you need to make the post request using the requests python library, something like this
x = requests.post(url, data = payload, headers = headers)
There are other things you have to be aware of
- I saw the page you put in the code and I noticed the form action is actually "https://www.trendyol.com/Login/CreateUser" instead of "https://www.trendyol.com/login"
- There is a hidden field named "__RequestVerificationToken" which has a value that changes everytime you visit the page. This is the csrf validation token and you have to include it in your request otherwise the server will reject any of them. Maybe this SO answer will help you: https://stackoverflow.com/questions/13567507/passing-csrftoken-with-python-requests (https://stackoverflow.com/questions/13567507/passing-csrftoken-with-python-requests)
- Last but not least, I don't know exactly how python deals with SSL, but because the page you are trying to connect to has https you need to include the certificate or maybe disable the verification for SSL. I found this https://www.geeksforgeeks.org/ssl-certificate-verification-python-requests/ (https://www.geeksforgeeks.org/ssl-certificate-verification-python-requests/)