{"id":2639,"date":"2016-03-11T22:04:58","date_gmt":"2016-03-11T14:04:58","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2639"},"modified":"2016-03-11T22:04:58","modified_gmt":"2016-03-11T14:04:58","slug":"wget%e5%91%bd%e4%bb%a4%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2639.html","title":{"rendered":"wget\u547d\u4ee4\u7684\u4f7f\u7528"},"content":{"rendered":"<p>=Start=<\/p>\n<h6>\u7f18\u7531\uff1a<\/h6>\n<p>\u4eca\u5929\u5728\u670d\u52a1\u5668\u4e0a\u6279\u91cf\u4e0b\u8f7d\u6587\u4ef6\u7684\u65f6\u5019\u7528\u5230\u4e86wget\u547d\u4ee4\uff0c\u671f\u95f4\u78b0\u5230\u4e86\u4e00\u4e9b\u5c0f\u95ee\u9898\uff0c\u5728\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u7684\u8fc7\u7a0b\u4e2d\u603b\u7ed3\u4e86\u4e00\u4e9b\u5e38\u7528\u7684wget\u547d\u4ee4\u9009\u9879\uff0c\u5206\u522b\u5e94\u5bf9\u4e0d\u540c\u7684\u573a\u666f\uff0c\u5728\u6b64\u8bb0\u5f55\u4e00\u4e0b\uff0c\u65b9\u4fbf\u540e\u671f\u67e5\u9605\u3002<\/p>\n<h6>\u53c2\u8003\u8bf4\u660e\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">wget -O save_file_name $URL  #\u8bbe\u7f6e\u4e0b\u8f7d\u6587\u4ef6\u4fdd\u5b58\u5728\u672c\u5730\u7684\u540d\u5b57\n\nwget -i download_list.txt   #(\u6279\u91cf)\u4e0b\u8f7d\u6587\u4ef6\u4e2d\u51fa\u73b0\u7684\u76ee\u6807\u5217\u8868\n\nwget --no-clobber $URL      #(-nc)\u62d2\u7edd\u4e0b\u8f7d\u540c\u4e00\u6587\u4ef6\n\nwget --timestamping $URL    #(-N)\u5f00\u542f\u65f6\u95f4\u6233\u673a\u5236\uff0cwget\u4f1a\u4e0b\u8f7d\u8fdc\u7a0b\u65f6\u95f4\u6233\u66f4\u65b0\u7684\u6587\u4ef6\n\nwget -c $URL_old    #\u65ad\u70b9\u7eed\u4f20\uff0c\u7ee7\u7eed\u4e0b\u8f7d\n\nwget -b $URL        #\u540e\u53f0\u4e0b\u8f7d\n\nwget --timeout=5 $URL   #\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\n\nwget --limit-rate=100k $URL     #\u9650\u5236\u4e0b\u8f7d\u901f\u5ea6\n\nwget --wait=20 --limit-rate=20K $URL\nwget --random-wait --limit-rate=20K\n\nwget --http-user=narad --http-password=password $URL\nwget --ftp-user=narad --ftp-password=password $URL\n\nwget --no-check-certificate $URL    #\u7528\u4e8e\u4e0b\u8f7dHTTPS\u94fe\u63a5\n\nwget -U Mozilla $URL    #\u624b\u52a8\u8bbe\u7f6eUser-Agent<\/pre>\n<p>\u5176\u4e2d\u7684\u300c-nc\u300d\u9009\u9879\u5bf9\u4e8e\u67d0\u4e9b\u573a\u666f\u6765\u8bf4\u975e\u5e38\u5b9e\u7528\uff1a\u53ef\u4ee5<span style=\"color: #ff0000;\"><strong>\u907f\u514d\u91cd\u590d\u4e0b\u8f7d\uff01<\/strong><\/span><\/p>\n<p>\u5728\u4e0d\u77e5\u9053\u8fd9\u4e2a\u9009\u9879\u4e4b\u524d\uff0c\u6211\u81ea\u5df1\u90fd\u662f\u8fd9\u4e48\u7528\u7684\uff1a<\/p>\n<pre class=\"lang:default decode:true \"># \u5bf9 wget \u7684\u7b80\u5355\u5c01\u88c5\uff0c\u907f\u514d\u91cd\u590d\u4e0b\u8f7d\nfunction download() {\n    if [[ -f ${1##*\/} ]]; then\n        :\n    else\n        wget $1\n    fi\n}<\/pre>\n<p>\u8fd8\u6709<strong><span style=\"color: #ff0000;\">\u300c-N\u300d\u9009\u9879\uff0c\u4f7f\u7528\u65f6\u95f4\u6233\u673a\u5236\uff0c\u5728\u8fdc\u7a0b\u6587\u4ef6\u65f6\u95f4\u6233\u66f4\u65b0\u7684\u60c5\u51b5\u4e0b\u8fdb\u884c\u4e0b\u8f7d<\/span><\/strong>\uff1b\u4e4b\u524d\u6211\u662f\u901a\u8fc7curl\u547d\u4ee4\u5148\u67e5\u8be2\u8fdc\u7a0b\u6587\u4ef6\u7684\u5927\u5c0f\u548c\u672c\u5730\u5df2\u4e0b\u8f7d\u6587\u4ef6\u7684\u5927\u5c0f\u8fdb\u884c\u6bd4\u5bf9\uff0c\u5b58\u5728\u5dee\u5f02\u65f6\u624d\u8fdb\u884c\u66f4\u65b0\uff08\u4e2a\u4eba\u611f\u89c9\u8fd9\u4e2a\u5e94\u8be5\u8981\u6bd4wget\u547d\u4ee4\u7684\u300c-N\u300d\u9009\u9879\u8981\u51c6\u786e\u4e9b\uff09\uff0c\u4e4b\u524d\u5728\u6587\u7ae0\u300c<a href=\"http:\/\/ixyzero.com\/blog\/archives\/901.html\" target=\"_blank\">\u5982\u4f55\u5b9e\u65f6\u66f4\u65b0\u4e00\u4e9b\u6570\u636e\u6587\u4ef6\uff1f<\/a>\u300d\u4e2d\u6709\u8fc7\u8bf4\u660e\uff1a<\/p>\n<pre class=\"lang:default decode:true \">oldSize=`ls -l qqwry.dat.zip | awk '{print $5}'`\nnewSize=`curl -s -I http:\/\/www.newxing.com\/D6C47427E608\/qqwry.dat | grep Content-Length`\nif [$oldSize != $newSize];then\t#\u8fd9\u91cc\u5176\u5b9e\u65e2\u53ef\u4ee5\u4f5c\u4e3a\u5b57\u7b26\u4e32\u6bd4\u8f83\u4e5f\u53ef\u4ee5\u4f5c\u4e3a\u6570\u5b57\u8fdb\u884c\u6bd4\u8f83{\u53ea\u8981\u4e24\u8005\u4e0d\u540c\u5373\u53ef}\n\twget -O qqwry.dat.zip http:\/\/www.newxing.com\/D6C47427E608\/qqwry.dat\n\tunzip -o qqwry.dat.zip\nfi<\/pre>\n<p>\u5e38\u7528\u7684wget\u547d\u4ee4\u8fd8\u6709\u5f88\u591a\u7684\u300c\u9ed1\u79d1\u6280\u300d\uff0c\u5927\u5bb6\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u7684\u5b9e\u9645\u9700\u6c42\u8fdb\u884c\u6316\u6398\u3001\u4f7f\u7528\u3002<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/\" target=\"_blank\">http:\/\/www.tecmint.com\/10-wget-command-examples-in-linux\/<\/a><\/li>\n<li><a href=\"http:\/\/www.linuxjournal.com\/content\/downloading-entire-web-site-wget\" target=\"_blank\">http:\/\/www.linuxjournal.com\/content\/downloading-entire-web-site-wget<\/a><\/li>\n<li><a href=\"http:\/\/roclinux.cn\/?p=2107\" target=\"_blank\">http:\/\/roclinux.cn\/?p=2107<\/a><\/li>\n<li>=<\/li>\n<li><a href=\"http:\/\/www.kossboss.com\/linux---wget-full-website\" target=\"_blank\">http:\/\/www.kossboss.com\/linux&#8212;wget-full-website<\/a><\/li>\n<li><a href=\"http:\/\/linuxreviews.org\/quicktips\/wget\/\" target=\"_blank\">http:\/\/linuxreviews.org\/quicktips\/wget\/<\/a><\/li>\n<li><a href=\"http:\/\/www.thegeekstuff.com\/2009\/09\/the-ultimate-wget-download-guide-with-15-awesome-examples\/\" target=\"_blank\">http:\/\/www.thegeekstuff.com\/2009\/09\/the-ultimate-wget-download-guide-with-15-awesome-examples\/<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/8755229\/how-to-download-all-files-but-not-html-from-a-website-using-wget\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/8755229\/how-to-download-all-files-but-not-html-from-a-website-using-wget<\/a><\/li>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/273743\/using-wget-to-recursively-fetch-a-directory-with-arbitrary-files-in-it\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/273743\/using-wget-to-recursively-fetch-a-directory-with-arbitrary-files-in-it<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u4eca\u5929\u5728\u670d\u52a1\u5668\u4e0a\u6279\u91cf\u4e0b\u8f7d\u6587\u4ef6\u7684\u65f6\u5019\u7528\u5230\u4e86wget\u547d\u4ee4\uff0c\u671f\u95f4\u78b0\u5230\u4e86\u4e00\u4e9b\u5c0f\u95ee\u9898\uff0c\u5728\u89e3\u51b3\u8fd9\u4e9b\u95ee [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,12],"tags":[84,66],"class_list":["post-2639","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-tools","tag-curl","tag-wget"],"views":5511,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2639","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2639"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2639\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}