我有一个带有HTML表单的网站.登录后,将我带到start.php站点,然后将我重定向到overview.php.
我想从该服务器下载文件…当我单击ZIP文件的下载链接时,该链接后面的地址是:
getimage.php?path="vol/img"&id="4312432"
如何处理请求?我试图创建一个会话并使用正确的参数执行GET-Command …但是答案只是我未登录时会看到的网站.
c = requests.Session()
c.auth =('myusername', 'myPass')
request1 = c.get(myUrlToStart.PHP)
tex = request1.text
with open('data.zip', 'wb') as handle:
request2 = c.get(urlToGetImage.Php, params=payload2, stream=True)
print(request2.headers)
for block in request2.iter_content(1024):
if not block:
break
handle.write(block)
解决方法:
您正在做的是带有基本身份验证的请求.这不会填写页面上显示的表单.
如果您知道表单将POST请求发送到的URL,则可以尝试将表单数据直接发送到该URL
标签:python
来源: https://codeday.me/bug/20191122/2061967.html