wget: don't follow redirects

2019-01-23 01:03发布

问题:

How do I prevent wget from following redirects?

回答1:

--max-redirect 0

I haven't tried this, it will either allow none or allow infinite..



回答2:

Use curl without -L instead of wget.



回答3:

Some versions of wget have a --max-redirect option: See here



回答4:

wget follows up to 20 redirects by default. However, it does not span hosts. If you have asked wget to download example.com, it will not touch any resources at www.example.com. wget will detect this as a request to span to another host and decide against it.

In short, you should probably be executing:

wget --mirror www.example.com

Rather than

wget --mirror example.com

Now let's say the owner of www.example.com has several subdomains at example.com and we are interested in all of them. How to proceed?

Try this:

wget --mirror --domains=example.com example.com

wget will now visit all subdomains of example.com, including m.example.com and www.example.com.