【发布时间】:2016-08-23 22:14:51
【问题描述】:
我正在通过以下 URL 对脚本进行 POST 调用(我公司内部,因此无法从外部访问): https://opsdata.mycompany.com/scripts/finance/finance.exe
初始站点是一个 html 页面,其中包含供您输入数据的文本框,并且对上述 url 有一个 post 操作。但是,它会重定向到登录页面,该页面也位于上述 url,其中包含用户名和密码的文本框。我使用以下代码向登录页面提交数据:
post_url_finance = 'https://opsdata.*****.com/scripts/finance/finance.exe'
s = requests.session()
s.auth = {'USER_NAME': '*****', 'PASSWORD': '*****'}
proxies = {'http': 'http://proxy-***.****.com'}
要进行身份验证,我使用的是:
pageCert = requests.post(post_url_finance, proxies=proxies, verify=False)
这给了我一个回应:
<Response [200]>
C:\Python27\lib\site-packages\urllib3\connectionpool.py:768: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
但是,我需要发送我正在查询的数据以使用此信息:
values_finance = {'EMPLOYEE_TOTAL': '-----'}
当我第二次使用:
page = requests.post(post_url_finance, data=values_finance, proxies=proxies, verify=False)
我得到了同样的回复。
<Response [200]>
如何进行第二次调用 Post 检索我想要的数据?
【问题讨论】:
标签: python authentication post python-requests session-cookies