4

I am trying to mirror a complete website to another domain.

I am trying to use

wget -mk http://example.com

However the -k option leaves some URLs original while other are converted such as:

<link rel="stylesheet" href="http://example.com/templates/css/style.css" type="text/css" />
<!--[if lt IE 8]>
  <link rel="stylesheet" href="/templates/css/ie.css" type="text/css" />
<![endif]-->
<!--[if lt IE 7]>
  <link rel="stylesheet" href="/templates/css/ie6.css" type="text/css" />
<![endif]-->

Or img tags:

<img src="http://example.com/templates/img/logo.jpg"

While a-tags are converted properly.

These are from index.html, and the output of wget states, that index.html got converted

Converting example.com/index.html... 30-12

Why does this happen?

1

This from the wget manpage, which probably explains what you're seeing:

-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.

Without further details it's difficult to be more precise.

  • 1
    i also tried to use --page-requisites which should download all links but doesnt. commandline I used now wget --mirror --convert-links --adjust-extension --page-requisites --no-parent example.com but still css, and imgs are not downloaded – fdafgfdgfagfdagfdagfdagfdagfda Feb 6 '15 at 15:39
  • @Jherek are your missing css files, etc., really on the same website? (Remembering, of course, that example.net is not the same as www.example.net.) – roaima Feb 6 '15 at 16:34
1

It may be that there is a robots.txt file on the server. The option -e robots=off would help in that case. (It did for me in a similar situation.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.