0

i'm trying to make a list of websites into static websites, and i'm using this wget command

wget --quiet -E -H -k -nd -K -p -e robots=off #{url}

the result is mostly what i want, but all the urls on the index.html are relative like href="some_css.css" and i would like to add a specific domain to all the url like href="https://somedomain.com/some_css.css" does wget has support or any way of doing this?

1 Answer 1

1

The closest you're probably going to get is --convert-links.

From the man page:

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.

You'll have to do a search and replace on the domain (in the second bullet point) if want it to be different to the domain you downloaded the files from.

2
  • Thats actually the reverse of what i want, convert-links removes the existing domain, i want to add a domain to all of the converted links Commented Sep 17, 2020 at 14:29
  • @EduardoVeras It's removing the existing domain because you've downloaded the content the HTML is referencing (bullet point 1). If you want to keep the domain in there, don't download the referenced content. Commented Sep 17, 2020 at 14:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.