手机赌博apphow do i download an entire website for offline viewing? how do i save all the mp3s from a website to a folder on my computer? how do i download files that are behind a login page? how do i build a mini-version of google?
is a free utility - available for , and Linux (included) - that can help you accomplish all this and more. What makes it different from most download managers is that
wget手机赌博app can follow the HTML links on a web page and recursively download the files. It is the that a soldier had used to download thousands of secret documents from the US army’s Intranet that were later published on the Wikileaks website.
手机赌博appwget is extremely powerful, but like with most other command line programs, the plethora of options it supports can be intimidating to new users. thus what we have here’s a collection of wget commands that you can use to accomplish common tasks from downloading single files to mirroring entire websites. it will help if you can read through the but for the busy souls, these commands are ready to execute.
1. download a single file from the internet
手机赌博app2. download a file but save it locally under a different name
wget ‐‐output-document=filename.html example.com
3. download a file and save it in a specific folder
wget ‐‐directory-prefix=folder/subfolder example.com
4. resume an interrupted download previously started by wget itself
wget ‐‐continue example.com/big.file.iso
手机赌博app5. download a file but only if the version on server is newer than your local copy
wget ‐‐continue ‐‐timestamping wordpress.org/latest.zip
手机赌博app6. download multiple urls with wget. put the list of urls in another text file on separate lines and pass it to wget.
wget ‐‐input list-of-file-urls.txt
手机赌博app7. download a list of sequentially numbered files from a server
8. download a web page with all assets - like stylesheets and inline images - that are required to properly display the web page offline.
wget ‐‐page-requisites ‐‐span-hosts ‐‐convert-links ‐‐adjust-extension http://example.com/dir/file
9. download an entire website including all the linked pages and files
wget ‐‐execute robots=off ‐‐recursive ‐‐no-parent ‐‐continue ‐‐no-clobber http://example.com/
手机赌博app10. download all the mp3 files from a sub-directory
wget ‐‐level=1 ‐‐recursive ‐‐no-parent ‐‐accept mp3,MP3 http://example.com/mp3/
11. download all images from a website in a common folder
wget ‐‐directory-prefix=files/pictures ‐‐no-directories ‐‐recursive ‐‐no-clobber ‐‐accept jpg,gif,png,jpeg http://example.com/images/
12. download the pdf documents from a website through recursion but stay within specific domains.
wget ‐‐mirror ‐‐domains=abc.com,files.abc.com,docs.abc.com ‐‐accept=pdf http://abc.com/
13. download all files from a website but exclude a few directories.
wget ‐‐recursive ‐‐no-clobber ‐‐no-parent ‐‐exclude-directories /forums,/support http://example.com
wget can be used for downloading content from sites that are behind a login screen or ones that check for the http referer and the user-agent strings of the bot to prevent screen scraping.
手机赌博app14. download files from websites that check the user-agent and the http referer
wget ‐‐refer=http://google.com ‐‐user-agent="Mozilla/5.0 Firefox/4.0.1" http://nytimes.com
15. Download files from a password protected sites
wget ‐‐http-user=labnol ‐‐http-password=hello123 http://example.com/secret/file.zip
16. Fetch pages that are behind a login page. You need to replace
password with the actual form fields while the URL should point to the Form Submit (action) page.
wget ‐‐cookies=on ‐‐save-cookies cookies.txt ‐‐keep-session-cookies ‐‐post-data 'user=labnol&password=123' http://example.com/login.php_ _wget ‐‐cookies=on ‐‐load-cookies cookies.txt ‐‐keep-session-cookies http://example.com/paywall
17. find the size of a file without downloading it (look for contentlength in the response, the size is in bytes)
wget ‐‐spider ‐‐server-response http://example.com/file.iso
手机赌博app18. download a file and display the content on the screen without saving it locally.
wget ‐‐output-document - ‐‐quiet google.com/humans.txt
19. know the last modified date of a web page (check the lastmodified tag in the http header).
wget ‐‐server-response ‐‐spider http://cm71.com/
20. check the links on your website to ensure that they are working. the spider option will not save the pages locally.
wget ‐‐output-file=logfile.txt ‐‐recursive ‐‐spider http://example.com
Also see: Essential Linux Commands
The wget tool is essentially a spider that scrapes / leeches web pages but some web hosts may block these spiders with the robots.txt files. Also, wget will not follow links on web pages that use the rel=nofollow attribute.
You can however force wget to ignore the robots.txt and the nofollow directives by adding the switch ‐‐execute robots=off to all your wget commands. If a web host is blocking wget requests by looking at the User Agent string, you can always fake that with the ‐‐user-agent=Mozilla switch.
the wget command will put additional strain on the site’s server because it will continuously traverse the links and download files. a good scraper would therefore limit the retrieval rate and also include a wait period between consecutive fetch requests to reduce the server load.
wget ‐‐limit-rate=20k ‐‐wait=60 ‐‐random-wait ‐‐mirror example.com
手机赌博appin the above example, we have limited the download bandwidth rate to 20 kb/s and the wget utility will wait anywhere between 30s and 90 seconds before retrieving the next resource.
手机赌博appfinally, a little quiz. what do you think this wget command will do?
wget ‐‐span-hosts ‐‐level=inf ‐‐recursive dmoz.org