2012-11-23 39 views
50

एक पृष्ठ में .zip फ़ाइलों के एक सेट के लिंक शामिल हैं, जिनमें से सभी मैं डाउनलोड करना चाहता हूं। मुझे पता है कि यह wget और कर्ल द्वारा किया जा सकता है। यह कैसे किया जाता है?wget/curl का उपयोग कर किसी दिए गए वेब पेज पर .zip फ़ाइलों के सभी लिंक कैसे डाउनलोड करें?

उत्तर

83

आदेश है:

wget -r -np -l 1 -A zip http://example.com/download/ 

विकल्प अर्थ:

-r, --recursive   specify recursive download. 
-np, --no-parent   don't ascend to the parent directory. 
-l, --level=NUMBER  maximum recursion depth (inf or 0 for infinite). 
-A, --accept=LIST  comma-separated list of accepted extensions. 
+11

'-nd' (कोई निर्देशिका) ध्वज आसान है यदि आप कोई अतिरिक्त निर्देशिका नहीं बनाना चाहते हैं (यानी, सभी फाइल रूट फ़ोल्डर में होंगी)। –

+0

दिए गए पृष्ठ से गहराई से जाने के लिए मैं इस समाधान को कैसे ट्विक कर सकता हूं? मैंने कोशिश की- 20, लेकिन wget तत्काल बंद हो जाता है। – Wrench

47

समाधान से ऊपर मेरे लिए काम नहीं करता। मेरे लिए केवल इस एक काम करता है:

wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off [url of website] 

विकल्प अर्थ:

-r   recursive 
-l1   maximum recursion depth (1=use only this directory) 
-H   span hosts (visit other hosts in the recursion) 
-t1   Number of retries 
-nd   Don't make new directories, put downloaded files in this one 
-N   turn on timestamping 
-A.mp3  download only mp3s 
-erobots=off execute "robots.off" as if it were a part of .wgetrc 
+1

स्रोत: http://www.commandlinefu.com/commands/view/12498/download-all-music-files-off-of-a-website-using-wget –

+0

हाँ, धन्यवाद! मुझे याद नहीं आया कि यह कहां से आया था, क्या यह सिर्फ मेरी लिपियों में झूठ बोल रहा है। –

+0

क्षमा नहीं है। एक नया सवाल करो! ;) –

1

अन्य परिदृश्यों के लिए कुछ समानांतर जादू के साथ मैं का उपयोग करें:

curl [url] | grep -i [filending] | sed -n 's/.*href="\([^"]*\).*/\1/p' | parallel -N5 wget -