我目前正在使用 Python 请求,并且需要一个 CSRF 令牌来登录站点。根据我的理解 requests.Session() 获取 cookie,但显然我需要令牌。而且我想知道将它放在我的代码中的哪个位置。进口请求
user_name = input('Username:')
payload = {
'username': 'user_name',
'password': 'randompass123'
}
with requests.Session() as s:
p = s.post('https://examplenotarealpage.com', data=payload)
Run Code Online (Sandbox Code Playgroud) 所以我想检查当前的 URL 是否为 example.com (示例),然后如果是,则使用 if 执行以下操作: if current URL == example.com: then print something,但我的问题不是它我不知道如何使用 python 3 的请求来获取当前的 URL。我已经编写了代码,但这与我的要求无关,因为到目前为止我的代码中没有错误。所以我的问题是如何使用 Python 3 的请求获取当前 URL,任何帮助都很棒..谢谢!我到处都找过了,但找不到任何东西。