我正在尝试从需要登录的网站下载文件。 在尝试了几种方法之后,我目前的尝试是:
使用以下方法跳过登录页面:
wget --save-cookies cookies.txt --keep-session-cookies --delete-after --post-data 'username=my_username&password=my_password' http://example/login
,以HTTP代码200开头,后跟:
wget --load-cookies cookies.txt http://example/get_file?fname=filename.tar.gz
这只会导致wget将HTML文档保存在文件名下: “ get_file \?fname \ = vggface2_test.tar.gz”。 如果我改为包含之前的后参数:
wget --load-cookies cookies.txt --post-data="username=my_username&password=my_password" http://example/get_file?fname=filename.tar.gz
我得到HTML代码:403:禁止。
我尝试的另一件事是从浏览器中导出cookie(可在其上进行下载),将它们复制到txt文件中并使用它们,但是,这也会导致403:禁止。
有人知道为什么禁止我访问吗? 我必须在请求中添加隐藏的后参数吗?