【发布时间】:2017-03-28 14:07:24
【问题描述】:
我正在使用 python requests 模块来处理我正在抓取的特定网站上的请求。我对 HTTP 请求相当陌生,但我确实了解基础知识。这是情况。我想提交一个表单,我使用请求模块中的 post 方法来提交:
# I create a session
Session = requests.Session()
# I get the page from witch I'm going to post the url
Session.get(url)
# I create a dictionary containing all the data to post
PostData = {
'param1': 'data1',
'param2': 'data2',
}
# I post
Session.post(SubmitURL, data=PostData)
有什么方法可以检查数据是否已成功发布? .status_code 方法是检查它的好方法吗?
【问题讨论】:
标签: python http module python-requests