使用python提取CSV文件,其中使用基于cookie的身份验证

2024-03-28 19:28:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的石像鬼路由器有一个带宽.csv附带所有机器的详细信息的文件。你知道吗

访问带宽.csv文件的登录是必需的,据我所知,一个cookie存储在登录,然后文件可以下载。你知道吗

# Read CSV File
url='http://mygargoylerouter/utility/get_password_cookie.sh'
s =requests.session()
p = dict(postparms = 'mygargoylepassword')
headers = {'content-type': 'application/x-www-form-urlencoded'}
r = s.post(url,params = p,headers=headers)
print r
print r.text
c = r.cookies
r = requests.get('http://mygargoylerouter/bandwidth.csv', cookies = c, verify = False)

这是我的代码,但它似乎拉回来一个页面…我甚至不知道我是否登录。你知道吗

print r返回200


Tags: 文件csv机器httpurlgetcookie路由器