如何使用 Wget 跳过登录页面? [英] How to get past the login page with Wget?

查看:30
本文介绍了如何使用 Wget 跳过登录页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Wget 下载页面,但我无法通过登录屏幕.

I am trying to use Wget to download a page, but I cannot get past the login screen.

如何使用登录页面上的帖子数据发送用户名/密码,然后以经过身份验证的用户身份下载实际页面?

How do I send the username/password using post data on the login page and then download the actual page as an authenticated user?

推荐答案

基于手册页:

# Log in to the server.  This only needs to be done once.
wget --save-cookies cookies.txt \
     --keep-session-cookies \
     --post-data 'user=foo&password=bar' \
     --delete-after \
     http://server.com/auth.php

# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
     http://server.com/interesting/article.php

确保 --post-data 参数正确percent-编码(尤其是&符号!)否则请求可能会失败.还要确保 userpassword 是正确的密钥;您可以通过搜索登录页面的 HTML 来找出正确的密钥(查看浏览器的检查元素"功能并在用户名和密码字段中找到 name 属性).

Make sure the --post-data parameter is properly percent-encoded (especially ampersands!) or the request will probably fail. Also make sure that user and password are the correct keys; you can find out the correct keys by sleuthing the HTML of the login page (look into your browser’s "inspect element" feature and find the name attribute on the username and password fields).

这篇关于如何使用 Wget 跳过登录页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆