小编Noa*_*ah 的帖子

使用 python 请求获取 CSRF 令牌

我目前正在使用 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)

python csrf python-3.x python-requests

7
推荐指数
2
解决办法
2万
查看次数

使用 requests python 3.7.0 检查网页的当前 url

所以我想检查当前的 URL 是否为 example.com (示例),然后如果是,则使用 if 执行以下操作: if current URL == example.com: then print something,但我的问题不是它我不知道如何使用 python 3 的请求来获取当前的 URL。我已经编写了代码,但这与我的要求无关,因为到目前为止我的代码中没有错误。所以我的问题是如何使用 Python 3 的请求获取当前 URL,任何帮助都很棒..谢谢!我到处都找过了,但找不到任何东西。

python python-3.x python-requests

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

python ×2

python-3.x ×2

python-requests ×2

csrf ×1