wget的身份验证 [英] wget with authentication
问题描述
我怎样才能下载需要用户名和密码,网页?
How can I download a webpage that require a username and password?
例如我想下载此页我输入用户名和密码后:
For example I want to download this page after I have entered username and password:
http://forum.ubuntu-it.org/index.php
推荐答案
尝试解决$ P $这里psented:
Try the solution presented here:
-
<一个href=\"http://www.unix.com/shell-programming-scripting/131020-using-wget-curl-http-post-authentication.html\">http://www.unix.com/shell-programming-scripting/131020-using-wget-curl-http-post-authentication.html
# Log in to the server. This can be done only once.
wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
http://server.com/auth.php
# Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
-p http://server.com/interesting/article.php
请注意别人谁可能在这个跌跌:
Note for others who might stumble on this:
- 上面的模拟用户做一个手动登录到具有两个输入字段的表单站点:一个名为
用户
和一个名为密码
- 的形式有它
动作
属性设置为http://server.com/auth.php
- 形式不使用JavaScript
- ,它使用JavaScript是一种很好的提示
的onsubmit
表单元素上的属性 - 请注意,这远不是唯一的方法来设置属性 - 使用JavaScript页面或任何静态或动态加载脚本文件上的任何地方可以改变表单元素
- The above simulates the user doing a manual login to a site which has a form with two input fields: one named
user
and one namedpassword
- The form has it's
action
attribute set tohttp://server.com/auth.php
- The form doesn't use JavaScript
- A good hint that it uses JavaScript is
onsubmit
attribute on the form element - Note that this is far from the only way to set the attributes - using JavaScript anywhere on the page or any of the statically or dynamically loaded script files can change the form elements
所以,如果属性的名称和形式操作URL不同,则需要将相应的参数更改为第一个
的wget
命令。So, if the attribute names and the form action url are different, you need to change the parameters to the first
wget
command appropriately.如果它使用JavaScript,有机会的话也不会在所有的工作 - 例如,在有机磷农药网站的例子中,它使用客户端的JavaScript散列,因此,使用
的wget
不设置窗体上必要的字段(在Ubuntu的情况下,外呼现场,hash_passwrd
字段)。If it uses JavaScript, there is a chance it will not work at all - e.g. in the case of OPs website example, it uses client JavaScript hashing, so the outside call using
wget
doesn't set the necessary fields on the form (in the case of the Ubuntu site,hash_passwrd
field).这篇关于wget的身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- A good hint that it uses JavaScript is
- ,它使用JavaScript是一种很好的提示