首页 > 解决方案 > 我想创建一个帐户生成器,但它给了我一个 404 on request URL

问题描述

这是我的代码,我真的不知道每次运行 URL 确实存在的代码时它给我一个 404 的问题是什么。任何帮助表示赞赏,顺便说一句,我对请求很陌生。据我所知,该网站没有太多保护,它也使用 cloudflare,但在检查浏览器的地方并不多。‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎ ‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎‎</p>

import requests
import randominfo
from requests.models import Response
import random
import string
import time

lenght = 15

lower = string.ascii_lowercase
upper = string.ascii_uppercase
num = string.digits
sym = string.punctuation

all = lower + upper + num + sym

temp = random.sample(all,lenght)

password = "".join(temp)

with open(path, 'r') as configFile:
    catchall = configFile.read()

login = randominfo.get_first_name() + '.' + randominfo.get_last_name() + catchall
passwordInput = password
passwordVeryfication = password

URLGet = 'https://de.afew-store.com'
url = 'https://de.afew-store.com/account/register'

RequestHeaders = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
    'referer': 'https://de.afew-store.com/',
    'content-language': 'de',
    'method': 'POST',
    'server': 'cloudflare',
    'x-content-type-options': 'nosniff',
    'path': 'account',
    'scheme': 'https',
}

getHeaders = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
    'location': 'https://de.afew-store.com/',
    'server': 'cloudflare',
    'x-content-type-options': 'nosniff',
    'path': 'account',
    'scheme': 'https',
}


firstName = randominfo.get_first_name()
lastName = randominfo.get_last_name()

customerEmail = firstName + lastName + catchall

s = requests.session()
signup = s.get(URLGet, headers=getHeaders)


payload = {
    'form_type': 'create_customer',
    'utf8': '✓',
    'customer[tags]': 'lang:en',
    'customer[first_name]': firstName,
    'customer[last_name]': lastName,
    'customer[email]': customerEmail,
    'customer[password]': password,
}
login_info = s.post(url, headers=RequestHeaders, data=payload)


print(login_info.status_code)

标签: pythonpython-requestsaccount

解决方案


主机https://de.aew-store.com未知。也许你打错了

ping https://de.afew-store.com
ping: cannot resolve https://de.afew-store.com: Unknown host

推荐阅读