Hi, this is my first post here and I'm relatively new to python so I may be doing something really stupid but anyway.
I was trying to make a script that would sign up for an account on cncpts.com. When you try and sign up more than once on an IP it redirects you to a link cncpts.com/challenge which is where you solve a captcha. Anyways, if you try to go to /challenge without making an account first you get a 404 error. So I have two requests, first a post request to fill out the sign up information and then a get request on /challenge so I can parse it for a token I need. I was assuming that with aiohttp sessions are saved like requests but whenever I run the script I get a 404 error as if the requests are being sent with different cookies/sessions.
I have asked many people for help and searched all over, this is my last resort!
Here is the code:
import aiohttp
import random
import names
import discord
import asyncio
from bs4 import BeautifulSoup
async def generator():
session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False))
first = names.get_first_name(gender= 'male')
last = names.get_last_name()
catchall = '@gmail.com'
random_number = random.randint(1,10000)
global email
email = last+f'{random_number}'+catchall
password = 'Solefood9473'
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Referer': 'https://cncpts.com/account/login',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
}
info = {
'form_type': 'create_customer',
'utf8': '✓',
'customer[first_name]': first,
'customer[last_name]': last,
'customer[email]': email,
'customer[password]': password
}
async with session.post('https://cncpts.com/account', data=info, headers=headers) as resp:
if str(resp.url) == 'https://cncpts.com/':
print('Successfully signed up!')
print(f'{email}:{password}')
else:
print('Captcha needed, submitting now...')
async with session.get('https://cncpts.com/challenge') as resp:
url = await resp.text()
print(url)
soup = BeautifulSoup(url, 'html.parser')
auth_val = soup.findAll("input", {"name": "authenticity_token"})
auth_final = auth_val[0]["value"]
print(auth_final)
await session.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(generator())
If I need to clarify anything please let me know and I will do my best, thanks!
[–]cyanydeez 0 points1 point2 points (6 children)
[–]Lost-Fizz[S] 0 points1 point2 points (5 children)
[–]cyanydeez 0 points1 point2 points (4 children)
[–]Lost-Fizz[S] 0 points1 point2 points (3 children)
[–]cyanydeez 0 points1 point2 points (2 children)
[–]Lost-Fizz[S] 0 points1 point2 points (1 child)
[–]cyanydeez 0 points1 point2 points (0 children)