Navigation X
ALERT
Click here to register with a few steps and explore all our cool stuff we have to offer!



   419

Help with python

by Mern69 - 30 November, 2023 - 09:38 PM
This post is by a banned member (Mern69) - Unhide
Mern69  
Infinity
9
Posts
1
Threads
3 Years of service
#1
Im trying to create an account creator for https://myanimelist.net/ but no matter what I do I cant get it to work. 
Here is what I wrote so far
Code:
import          requests
import          json
import          cloudscraper
import          urllib.parse

def generate_captcha():
    anchor_url = "https://www.google.com/recaptcha/api2/anchor?ar=1&k=6Ld_1aIZAAAAAF6bNdR67ICKIaeXLKlbhE7t2Qz4&co=aHR0cHM6Ly9teWFuaW1lbGlzdC5uZXQ6NDQz&hl=en&v=-QbJqHfGOUB8nuVRLvzFLVed&size=invisible&cb=rqazcek22coy"
    k = anchor_url.split('k=')[1].split("&")[0]
    co = anchor_url.split("co=")[1].split("&")[0]
    v = anchor_url.split("v=")[1].split("&")[0]
    x = session.get(anchor_url).text
    token = x.split('recaptcha-token" value="')[1].split('">')[0]
    payload = {
        "v": v,
        "reason": "q",
        "c": token,
        "k": k,
        "co": co,
        "hl": "en",
        "size": "invisible",
    }
    key = session.post(f"https://www.google.com/recaptcha/api2/reload?k={k}", data=payload)
    return key.text.split('"rresp","')[1].split('"')[0]

def generate_data():
    x = session.get('https://myanimelist.net/register.php?from=%2F')
    csrf = x.text.split("name='csrf_token' content='")[1].split("'")[0]
    return csrf, x.cookies

def run_validation(): # prob not needed
    payload_email = f"email={email}"
    payload_user = f"user_name={username}"
    payload_password = f"password={password}&user_name={username}&email={email}"
    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip, deflate, br",
        "Content-Type": "application/x-www-form-urlencoded",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        "X-Csrf-Token": csrf,
        "X-Referral-Path": "/register.php?from=%2F&",
        "X-Requested-With": "XMLHttpRequest"
    }
    x = session.post("https://myanimelist.net/signup/username/validate", data=urllib.parse.urlencode(payload_user), headers=headers,
                     cookies=cookies)
    y = session.post('https://myanimelist.net/signup/email/validate', data=urllib.parse.urlencode(payload_email), headers=headers,
                     cookies=cookies)
    z = session.post('https://myanimelist.net/signup/password/validate', data=urllib.parse.urlencode(payload_password), headers=headers,
                     cookies=cookies)
    print(x.status_code, y.status_code, z.status_code)

def create():
    data = {
        "email": email,
        "user_name": username,
        "password": password,
        "birthday[day]": 11, # change this to nested dict later
        "birthday[month]": 17,
        "birthday[year]": 2006,
        "agreement": 1,
        "sns": "",
        "csrf_token": csrf,
        "g-recaptcha-response": generate_captcha()
    }
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        "Content-Type": "application/x-www-form-urlencoded",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate, br",
    }
    x = scraper.post("https://myanimelist.net/register.php?from=%2F", data=urllib.parse.urlencode(data), headers=headers, cookies=cookies)
    return x.text

if __name__ == "__main__":
    scraper = cloudscraper.create_scraper() # tried this bc it establishes an ssl context by default but it didn't work either
   
    session = requests.Session()
    email = "asaiaosbufabb@gmail.com"#.replace("@", "%40") # any email for now
    username = "a0qashfoy72g" # Between 2 and 16 characters
    password = "shduag7AA100!!" # 6 - 50 characters,  at least two of the following: uppercase, lowercase, numbers and symbols
    csrf, cookies = generate_data()
    cr = create()
    if "Junk" in cr: # when successful page will have a think telling you to check ur email/junk mail
        print("Success")
    else: # most commonly error 500 or try refreshing the page
        print("Failed")

Any ideas or help appreciated [Image: pepeglad.png]
This post is by a banned member (ducky6969) - Unhide
ducky6969  
Supreme
278
Posts
36
Threads
2 Years of service
#2

  1. The initial requests to both MyAnimeList and Google Captcha services are successful.
  2. The POST request to MyAnimeList for registration (
    Code:
    /register.php
    ) resulted in a 500 Internal Server Error.
Code:
 
import requests
import json
import cloudscraper
import urllib.parse
import logging
import time
logging.basicConfig(level=logging.DEBUG)
def generate_captcha(session):
    anchor_url = "https://www.google.com/recaptcha/api2/anchor?ar=1&k=6Ld_1aIZAAAAAF6bNdR67ICKIaeXLKlbhE7t2Qz4&co=aHR0cHM6Ly9teWFuaW1lbGlzdC5uZXQ6NDQz&hl=en&v=-QbJqHfGOUB8nuVRLvzFLVed&size=invisible&cb=rqazcek22coy"
    k = anchor_url.split('k=')[1].split("&")[0]
    co = anchor_url.split("co=")[1].split("&")[0]
    v = anchor_url.split("v=")[1].split("&")[0]
    x = session.get(anchor_url).text
    token = x.split('recaptcha-token" value="')[1].split('">')[0]
    payload = {
        "v": v,
        "reason": "q",
        "c": token,
        "k": k,
        "co": co,
        "hl": "en",
        "size": "invisible",
    }
    key = session.post(f"https://www.google.com/recaptcha/api2/reload?k={k}", data=payload)
    return key.text.split('"rresp","')[1].split('"')[0]
def generate_data(session):
    x = session.get('https://myanimelist.net/register.php?from=%2F')
    csrf = x.text.split("name='csrf_token' content='")[1].split("'")[0]
    return csrf, x.cookies
def create(session, csrf, cookies, email, username, password):
    data = {
        "email": email,
        "user_name": username,
        "password": password,
        "birthday[day]": 11, # change this to nested dict later
        "birthday[month]": 17,
        "birthday[year]": 2006,
        "agreement": 1,
        "sns": "",
        "csrf_token": csrf,
        "g-recaptcha-response": generate_captcha(session)
    }
    headers = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
        "Content-Type": "application/x-www-form-urlencoded",
        "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
        "Accept-Encoding": "gzip, deflate, br",
    }
    x = session.post("https://myanimelist.net/register.php?from=%2F", data=urllib.parse.urlencode(data), headers=headers, cookies=cookies)
    return x.text
if __name__ == "__main__":
    session = requests.Session()
    email = "asaiaosbufabb@gmail.com"
    username = "a0qashfoy72g"
    password = "shduag7AA100!!"
    try:
        csrf, cookies = generate_data(session)
        cr = create(session, csrf, cookies, email, username, password)
        if "Junk" in cr:
            print("Success")
        else:
            print("Failed")
    except Exception as e:
        logging.error(f"An error occurred: {str(e)}")
[Image: juice-wrld.gif]

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
or
Sign in
Already have an account? Sign in here.


Forum Jump:


Users browsing this thread: 1 Guest(s)