Converting Relative URLs to Absolute URLs

In summary, the conversation discusses the issue of relative URLs within a folder that contains pages with links. The speaker mentions using a utility such as HTTrack or DownThemAll to download the pages, but the problem is that the saved pages have relative URLs that point to a server they cannot access. They ask if there is a program that can convert relative URLs to absolute URLs within an HTML page, and if it needs to be coded in a specific language. The speaker also suggests an alternative of tricking the website tracker into interpreting the base directory of the URL. They mention knowing of a program that automatically does this, but have forgotten its name.
  • #1
Simfish
Gold Member
823
2
Within all pages within a folder.

So I downloaded a number of pages that have links to pages that I want to download (using a utility such as HTTrack or DownThemAll). The problem is that the URLs of the pages are all relative, so when I save the pages to an external server (I have to do that, since the pages are temporary PHP search pages that HTTrack could not mirror), the URLs point to pages within the server that I cannot access.

So example...

http://the-scholars.com/viewtopic.php?t=10151

is converted to...

http://students.washington.edu/achen89/kong/viewtopic.php?t=10151 (where I saved the search page to).

So is there a program that allows one to parse all relative URLs to absolute URLs within an HTML page? (so that I can then use Httrack/DownThemAll on the saved page and then mirror all links within that page) Does the program have to be coded in a particular language? (C, Perl, Python?) I tried searching for one and found it at perlmonks.com, but couldn't turn it into a working .exe file (though I have no experience in compiling Perl)
 
Last edited by a moderator:
Computer science news on Phys.org
  • #2
On a side note, an alternative would be to "trick" the website tracker into interpreting the base directory of the URL as http://the-scholars.com
 
  • #3
Look for webpage mirroring programs that support this. Any good mirroring program will do this automatically though.

I used to know of a good one that did this automatically, but I've long since forgotten about it. If I run across it somewhere, I'll let you know.
 
Last edited:

Related to Converting Relative URLs to Absolute URLs

1. What is the difference between relative and absolute URLs?

Relative URLs are URL addresses that are relative to the current page or location, while absolute URLs are the complete address of a webpage including the protocol, domain, and path.

2. Why is it important to convert relative URLs to absolute URLs?

Converting relative URLs to absolute URLs ensures that all links and resources on a webpage are correctly linked and accessible. This is particularly important when sharing or moving a webpage to a different location or domain.

3. How can I convert relative URLs to absolute URLs?

There are several ways to convert relative URLs to absolute URLs, such as using an online converter tool, manually editing the URLs in the code, or using a programming language or library specifically designed for this purpose.

4. What are the potential issues with using relative URLs?

Using relative URLs can lead to broken links if the webpage is moved to a different location or if the user is viewing the webpage from a different directory. This can also cause issues with search engine optimization and indexing.

5. Can I use both relative and absolute URLs on a webpage?

Yes, it is possible to use both relative and absolute URLs on a webpage. However, it is important to ensure that all links and resources are consistently formatted to avoid any potential issues.

Similar threads

  • Computing and Technology
Replies
3
Views
1K
  • Sticky
  • General Discussion
Replies
0
Views
310
  • Electrical Engineering
Replies
14
Views
908
  • Computing and Technology
Replies
14
Views
3K
  • Special and General Relativity
Replies
10
Views
1K
  • High Energy, Nuclear, Particle Physics
Replies
2
Views
1K
  • Electrical Engineering
Replies
10
Views
1K
  • Astronomy and Astrophysics
Replies
21
Views
1K
Replies
6
Views
2K
  • Special and General Relativity
Replies
10
Views
2K
Back
Top