页面明显存在时出现404错误

时间:2019-05-25 08:05:06

标签: python python-requests

因此,我尝试发出POST请求,但出现404错误。当我在浏览器中点击链接时,它的加载就很好了,但是当我为POST响应打印文本时,我得到的只是一个404页。

我尝试使用标头,并尝试使用“身份验证令牌”

atc = requests.post('https://www.saintalfred.com/cart/add.js', data = cart)
print(atc.text)

atc.cookies.get_dict()

r = requests.post("https://www.saintalfred.com/checkout", data=params, timeout = 20, cookies = atc.cookies)

print(r.text)

html = r.text

r.cookies.get_dict()


checkouttoken = re.search('DF_CHECKOUT_TOKEN = "(.*?)"', html)
authenticityToken = re.search('authenticity_token" value="(.*?)"',html)

print(checkouttoken.group(1))
print(authenticityToken.group(1))
aaaaa = checkouttoken.group(1).split('{fun')

aaaaaa = ''.join(aaaaa)

print(aaaaaa)

urlthing = "https://www.saintalfred.com/2681785/checkouts/" + aaaaaa + '?_method=patch&authenticity_token=' + authenticityToken.group(1)
print(urlthing)

headers = {'User Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3'}

z = requests.post(urlthing, data=params, timeout = 20, headers = headers, cookies = r.cookies)

print(z.text)

预期:不是404

实际:404页。

0 个答案:

没有答案