【发布时间】:2014-10-12 22:25:50
【问题描述】:
这不会通过登录屏幕。我认为我没有正确传递 CSRF 令牌。我该怎么做?
from bs4 import BeautifulSoup
import requests
url = 'https://app.greenhouse.io/people/new?hiring_plan_id=24047'
cookies = {'_session_id':'my_session_id'}
client = requests.session()
soup = BeautifulSoup(client.get(url, cookies=cookies).content)
csrf_metatags = soup.find_all('meta',attrs={'name':'csrf-token'})[0].get('content')
posting_data = dict(person_first_name='Morgan') ## this is what I want to post to the form
headers = dict(Referer=url, csrf_token=csrf_metatags)
r = client.post(url, data=posting_data, headers=headers)
谢谢!
【问题讨论】:
-
尝试将 csrf 令牌放入 posting_data 字典中