Can wget convert links within a local html document?

6

I know that wget can fetch a remote page and its dependencies and rewrite the html so that image src attributes reference the newly downloaded images.

I am trying to convert local html files that reference images on the Internet. I'm using

wget --mirror --page-requisites --convert-links \
     --directory-prefix=foo \
     --force-html \
     --input-file=my_file.html

All of the referenced images are downloaded to the appropriate places in foo/ but the src attributes in my_file.html aren't being changed.

Kevin L.

Posted 2011-07-07T03:03:59.767

Reputation: 171

Question was closed 2014-12-19T19:15:51.987

3This question is NOT a duplicate of the referenced question. In this question, the OP is using --convert-links which is a synonym for -k. The referenced question is asking what to do in the event that -k was not used. This question, on the other hand, is asking how to use the -k option with a local html file. I am currently having the same problem. I am using -k and, thanks to the OP's question, I have figured out how to use --input-file for a local input. However, just like the OP, the links in the html file are not being updated. – Evan de la Cruz – 2017-02-22T17:07:44.430

Can't you use regex to fix them? – None – 2011-07-10T04:35:45.080

Yes, I was hoping that I could use wget's built in functionality, but I ended up replacing the attributes manually. – None – 2011-07-11T14:30:25.067

Answers

2

Try this:

 wget --recursive   --page-requisites --html-extension=on --convert-links="on" --domains="www.thesite.com" --no-parent http://www.thesite.com  

This will bring you an entire website locally. just tried it, working fine.
with local resources

fatnjazzy

Posted 2011-07-07T03:03:59.767

Reputation: 169

1there is no URL. It is a local HTML file. – Evan de la Cruz – 2017-02-22T17:09:41.867

1I already have the website; the problem was that the links weren't being rewritten. in my_file.html – None – 2011-07-11T14:29:27.167

1@Kevin L. Please provide the site url that you want to download. BTW, if the links made in JavaScript, you cant do it with wget. nevetheless, provide the url. – fatnjazzy – 2011-07-12T04:09:45.470