2011-06-14 20 views
164

मैं एक वेब पेज की एक स्थानीय प्रति डाउनलोड करने और सीएसएस, छवियों, जावास्क्रिप्ट के सभी प्राप्त करने के लिए, आदिवेबपृष्ठ का एक काम कर रहे स्थानीय प्रतिलिपि डाउनलोड

पिछले विचार-विमर्श में (जैसे here और here, दोनों चाहते हैं जिनमें से दो साल से अधिक पुराना है), दो सुझाव आम तौर पर आगे दिए जाते हैं: wget -p और httrack। हालांकि, ये सुझाव दोनों विफल हो जाते हैं। मैं कार्य को पूरा करने के लिए इन उपकरणों में से किसी एक का उपयोग करने में सहायता की बहुत सराहना करता हूं; विकल्प भी सुंदर हैं।


विकल्प 1: wget -p

wget -p सफलतापूर्वक वेब पृष्ठ के आवश्यक शर्तें के सभी डाउनलोड करता है (सीएसएस, छवियों, जे एस)। हालांकि, जब मैं एक वेब ब्राउज़र में स्थानीय प्रतिलिपि लोड करता हूं, तो पृष्ठ पूर्वापेक्षाएँ लोड करने में असमर्थ है क्योंकि उन पूर्वापेक्षाएँ के पथ वेब पर संस्करण से संशोधित नहीं किए गए हैं।

उदाहरण के लिए:

  • पृष्ठ के HTML में, <link rel="stylesheet href="/stylesheets/foo.css" />foo.css
  • सीएसएस फ़ाइल में की नई रिश्तेदार पथ को इंगित करने के लिए सही करने की आवश्यकता होगी, background-image: url(/images/bar.png) इसी तरह समायोजित करने की आवश्यकता होगी।

क्या wget -p को संशोधित करने का कोई तरीका है ताकि पथ सही हों?


विकल्प 2: httrack

httrack संपूर्ण वेबसाइटें मिरर के लिए एक महान उपकरण की तरह लगता है, लेकिन यह है कि यह कैसे उपयोग करने के लिए एक ही पृष्ठ की स्थानीय प्रतिलिपि बनाने के लिए मेरे लिए स्पष्ट नहीं है। इस विषय के बारे में प्रेरणा मंचों में चर्चा का एक बड़ा सौदा है (उदा। here) लेकिन किसी को भी बुलेट प्रूफ समाधान नहीं लगता है।


विकल्प 3: दूसरा उपकरण?

कुछ लोगों ने भुगतान किए गए टूल का सुझाव दिया है, लेकिन मुझे विश्वास नहीं है कि वहां एक मुफ्त समाधान नहीं है।

बहुत बहुत धन्यवाद!

+14

जवाब काम नहीं करता है, की कोशिश: 'wget -E एच -k -K -p http: // example.com' - केवल इस के लिए काम किया मुझे। क्रेडिट: http: // superuser।कॉम/ए/136335/94039 –

+0

ऐसा करने के लिए सॉफ्टवेयर भी है, [टेलीपोर्ट प्रो] (http://www.tenmax.com/teleport/pro/home.htm)। – pbies

+0

'wget --random-wait -r -p -e robots = off -U mozilla http: // www.example.com' – davidcondrey

उत्तर

207

wget आप जो पूछ रहे हैं वह करने में सक्षम है। बस निम्न प्रयास करें:

wget -p -k http://www.example.com/ 

-p आप सभी आवश्यक तत्वों को सही ढंग से (सीएसएस, छवि, आदि) साइट को देखने के मिल जाएगा। -k सभी लिंक को बदल देगा (सीएसएस & छवियों के लिए उनको शामिल करने के लिए) ताकि आप ऑफ़लाइन पृष्ठ को ऑनलाइन दिखाई दे सकें।

Wget डॉक्स से:

‘-k’ 
‘--convert-links’ 
After the download is complete, convert the links in the document to make them 
suitable for local viewing. This affects not only the visible hyperlinks, but 
any part of the document that links to external content, such as embedded images, 
links to style sheets, hyperlinks to non-html content, etc. 

Each link will be changed in one of the two ways: 

    The links to files that have been downloaded by Wget will be changed to refer 
    to the file they point to as a relative link. 

    Example: if the downloaded file /foo/doc.html links to /bar/img.gif, also 
    downloaded, then the link in doc.html will be modified to point to 
    ‘../bar/img.gif’. This kind of transformation works reliably for arbitrary 
    combinations of directories. 

    The links to files that have not been downloaded by Wget will be changed to 
    include host name and absolute path of the location they point to. 

    Example: if the downloaded file /foo/doc.html links to /bar/img.gif (or to 
    ../bar/img.gif), then the link in doc.html will be modified to point to 
    http://hostname/bar/img.gif. 

Because of this, local browsing works reliably: if a linked file was downloaded, 
the link will refer to its local name; if it was not downloaded, the link will 
refer to its full Internet address rather than presenting a broken link. The fact 
that the former links are converted to relative links ensures that you can move 
the downloaded hierarchy to another directory. 

Note that only at the end of the download can Wget know which links have been 
downloaded. Because of that, the work done by ‘-k’ will be performed at the end 
of all the downloads. 
+0

धन्यवाद !! कोई विचार नहीं कि मैं उस विकल्प को कैसे चूक गया। – brahn

+2

मैंने कोशिश की, लेकिन किसी भी तरह से आंतरिक लिंक जैसे 'index.html # link-to-element-on-same-page' ने काम करना बंद कर दिया। – rhand

+1

पूरी साइट: http://snipplr.com/view/23838/downloading-an-entire-web-site-with-wget/ –

संबंधित मुद्दे