Pobierz działającą lokalną kopię strony internetowej [zamknięta]

Chciałbym pobrać lokalną kopię strony internetowej i pobrać wszystkie css, obrazy, javascript itp.

W poprzednich dyskusjach (np. tutaj i tutaj , z których oba mają więcej niż dwa lata), na ogół wysuwa się dwie sugestie: wget -p i httrack . Jednak obie te sugestie zawodzą. Byłbym bardzo wdzięczny za pomoc w użyciu jednego z tych narzędzi do wykonania zadania; alternatywy są również piękne.


Opcja 1: wget -p

wget -p pomyślnie pobiera wszystkie wymagania wstępne strony internetowej (css, obrazy, js). Jednak gdy Ładuję kopię lokalną w przeglądarce internetowej, strona nie może załadować warunków wstępnych, ponieważ ścieżki do tych warunków wstępnych nie zostały zmodyfikowane w stosunku do wersji w Internecie.

Na przykład:

  • w html strony, <link rel="stylesheet href="/stylesheets/foo.css" /> będzie trzeba poprawić, aby wskazać nową ścieżkę względną foo.css
  • w css plik, background-image: url(/images/bar.png) będzie podobnie wymagał dostosowania.

Czy istnieje sposób na modyfikację wget -p tak, aby ścieżki były poprawne?


Wariant 2: httrack

httrack wydaje się świetnym narzędziem do dublowania całych witryn, ale nie jest dla mnie jasne, jak go użyć do tworzenia lokalnej kopii pojedynczej strony. Na forach httrack jest wiele dyskusji na ten temat (np. tutaj), ale chyba nikt nie ma kuloodpornego rozwiązanie.


Opcja 3: inne narzędzie?

Niektórzy sugerują płatne narzędzia, ale nie mogę uwierzyć, że nie ma darmowego rozwiązania.

Wielkie dzięki!

Author: Community, 2011-06-14

1 answers

Wget jest w stanie zrobić to, o co prosisz. Po prostu spróbuj:

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

-p zapewni Ci wszystkie wymagane elementy do prawidłowego wyświetlania witryny (css, obrazy itp.). -k zmieni wszystkie linki (aby zawierały te do CSS i obrazów), aby umożliwić przeglądanie strony w trybie offline, tak jak pojawiła się online.

Z Wget docs:

‘-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. 
 226
Author: serk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-10-16 20:50:02