views:

29

answers:

1

Hi I am using wget to copy a data from url and store it in a file.The url gives me a aspx file .I need to convert the aspx file to html file.SO I renamed the file from asd.aspx to asd.html.But in my file there are relative url which are not working in my html file.They should point to original url.How can i convert the relative url to their absolute url.Is there any way to achieve this,

for example

in original file link is 

href='../../login.html'

but when i open the html file in my browser the link is changed to

href="localhost/login.html"

but it should be

href="abc.com/login.html"

I hope i have clear the prob

+1  A: 

You should add <base href="http://www.abc.com/original/path"&gt; in the head section of the html file, wget will not rewrite the links automatically.

cristis
this means i need to edit the file everytime.This wget is in a shell script whcih runs periodically
ha22109
this edit can be done automatically, for instance when you rename the aspx to html you could have:$originalpath="http://www.abc.com/original/path" ;echo '<base href="'$originalpath'">' > file.html ;cat file.aspx >> file.html... browsers are tolerant about a <base> tag outside the <head>
cristis
@cristis thanks it worked for me
ha22109