I've downloaded a page with wget -m a good while ago. The internal links were not converted correctly so whenever the url includes a ? (GET parameters), the link is broken. If I change the ? in the URL with the %3F, the link works. However I obviously can't change all the question marks in the page since some of them are part of external URLs, javascript or other parts of the page.

Which tool can I use to fix these broken links?

The page doesn't exist anymore so I can not re-download it (with different wget options)


You could try to replace all ? with a certain context, like

sed 's/?\([a-z][A-Z]\)/%3F\1/g' a.html > b.html

This will process a.html (leaving it untouched) and create/overwrite b.html with modified HTML text.

The sed expression will find ? followed by a letter ([a-z][A-Z]), capture the letter (\(..\)), and replace it with %3F and the captured letter (\1).

Depending on your HTML file, you might have to refine the context to get a working result.

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.