Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8746373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:11:00+00:00 2026-06-13T12:11:00+00:00

i have simple app the gets all the links from web page , im

  • 0

i have simple app the gets all the links from web page , im using libexml2 to parse the html
and extract the html links that are inside the
and Qt QNetworkAccessManager for the http requests .
now the problem is how to detecte automatcly the host name of the links if i have for example :

<a href="thelink.html" >
or 
<a href="../../../thelink.html" >  
or
<a href="../foo/boo/thelink.html" > 
i need to convert it to full host path like :
( just example .. ) 
<a href="http://www.myhost.com/thelink.html" >
or 
<a href="http://www.myhost.com/foo/boo/thelink.html" >  
or
<a href="http://www.myhost.com/m/thelink.html" > 

is there any way to do it programmatically ? without manually doing string manipulation

if you know perl its called : Return a relative URL if possible
from the : http://search.cpan.org/~rse/lcwa-1.0.0/lib/lwp/lib/URI/URL.pm

$url->rel([$base])

code example that dosnt work ( Qt )
http://qt.digia.com/support/

QString s("/About-us/");
QString base("http://qt.digia.com");
QString urlForReq;

     if(!s.startsWith("http:"))
     {       
         QString uu = QUrl(s).toString();
         QString   rurl = baseUrl.resolved(QUrl(s)).toString();
         urlForReq = rurl;
     }

the urlForReq value is “/About-us/”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:11:01+00:00Added an answer on June 13, 2026 at 12:11 pm

    I have not verified if the algorithm mentioned by @sftrabbit is completely followed by this approach, but you can use QUrl::resolved to convert your relative URLs to absolute URLs:

    QUrl base("http://www.myhost.com/m/");
    qDebug() << base.resolved(QUrl("thelink.html")).toString();
    qDebug() << base.resolved(QUrl("../../../thelink.html")).toString();
    qDebug() << base.resolved(QUrl("../foo/boo/thelink.html")).toString();
    

    prints

    "http://www.myhost.com/m/thelink.html"
    "http://www.myhost.com/thelink.html"
    "http://www.myhost.com/foo/boo/thelink.html"
    

    I can not reproduce the code example from the question which does not work for the OP. The only issue is that the baseUrl object is missing in the code. The following SSCCE

    #include <QApplication>
    #include <QUrl>
    #include <QDebug>
    
    int main(int argc, char ** argv) {
    
        QApplication app( argc, argv );
    
        QString s("/About-us/");
        QString base("http://qt.digia.com");
        QString urlForReq;
        QUrl baseUrl(base);          // this was missing in the code from the question
        if(!s.startsWith("http:")) {       
            QString uu = QUrl(s).toString();
            QString rurl = baseUrl.resolved(QUrl(s)).toString();
            urlForReq = rurl;
        }
        qDebug() << "urlForReq:" << urlForReq;
    
        return 0;
    }
    

    prints

    urlForReq: "http://qt.digia.com/About-us/"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly simple android app, it gets protobuf data from a web
I have one simple app that suppose to get information from user and send
I have a simple catalogue app that lets users download product data from an
I'm using jQTouch to build a simple mobile app with an html/js/jquery form that
This is a real newbie question. I have simple app that selects a picture
I have simple Sinatra app. web.rb: require 'sinatra' get '/' do Hello end Gemfile:*
I have a simple app with a full screen UIWebView. This contains HTML generated
I have a simple app that will allow a user to tag a location.
Right so I have a simple app that consists of a calendar a Set
I'm now testing GKPeerPickerController. I have a simple app that just have a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.