日志网站python出现错误--验证提供的防伪令牌失败

日志网站python出现错误--验证提供的防伪令牌失败,python,web,python-requests,antiforgerytoken,Python,Web,Python Requests,Antiforgerytoken,我正在使用Python登录到一个网站并从中下载某些文件。然而,我得到了错误 cookie\uu RequestVerificationToken和表单字段 __RequestVerificationToken已交换 我已经尝试过提供防伪代币,但仍然无法理解到底是什么问题 以下是我当前的代码(Windows 7上的Python 2.7也将在MAC OS X上使用此代码): 请格式化您的代码,缩进在python中非常重要。谢谢您的回复,但这不是缩进或语法的问题。代码运行成功,但在网站上发布用户名+密

我正在使用Python登录到一个网站并从中下载某些文件。然而,我得到了错误

cookie\uu RequestVerificationToken和表单字段 __RequestVerificationToken已交换

我已经尝试过提供防伪代币,但仍然无法理解到底是什么问题

以下是我当前的代码(Windows 7上的Python 2.7也将在MAC OS X上使用此代码):


请格式化您的代码,缩进在python中非常重要。谢谢您的回复,但这不是缩进或语法的问题。代码运行成功,但在网站上发布用户名+密码时会产生错误。不,我指的是你问题中的代码。我不能那样读。哦,对不起。让我repost@t.m.adam我已经重新格式化了。谢谢。请格式化您的代码,缩进在python中非常重要。谢谢您的回复,但这不是缩进或语法的问题。代码运行成功,但在网站上发布用户名+密码时会产生错误。不,我指的是你问题中的代码。我不能那样读。哦,对不起。让我repost@t.m.adam我已经重新格式化了。谢谢
import bs4

from bs4 import BeautifulSoup 

import requests 

import re 

import sys

import time

USER_AGENT = []


USER_AGENT.append('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36')

USER_AGENT.append('Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36')

USER_AGENT.append('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36')

USER_AGENT.append('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1')

basic_URL = "https://app.whiskeysystems.com/Account/Login/"

complete_URL = basic_URL

print("\n**** Starting Program **** ")

print ("\nThe user-agent selected ---> " + USER_AGENT[2])
print("\nChecking if website ---> " + basic_URL +"  is UP or DOWN ?")

with requests.Session() as client:

    client.headers.update({'User-Agent':USER_AGENT[2]})
    c2 = client.get(complete_URL)  

    print("\nHTTP Status Code ---> " + str(c2.status_code))


    if ( int(c2.status_code) == 200):
        print("\nSuccessful!!!. Website is UP")

        print ("\nWill try to login to website using provided credentials")

        time.sleep(2)

        csrftoken = client.cookies['__RequestVerificationToken']
        print("\nThe __RequestVerificationToken value ---> " + str(csrftoken))

        time.sleep(1)
        login_data = dict(__RequestVerificationToken=csrftoken,Email='abc@def.com', Password='123456') 
        r1 = client.post(complete_URL, data=login_data)
        print r1.text


    else:
        print("\n Error !!!. Quitting the program, please see the website is UP or not. ")