Search code examples
c++qthttprequestqurl

QUrl: incorrect link


I have a link on Steam market listings:
http://steamcommunity.com/market/listings/730/%E2%98%85%20Gut%20Knife%20%7C%20Safari%20Mesh%20%28Battle-Scarred%29

Now I'm trying to do a get request using QNetworkAccessManager:

auto manager = new QNetworkAccessManager(this);
auto url = QUrl(link, QUrl::StrictMode);
auto request = QNetworkRequest(url);

manager->get(request);

But when I try to output my url, I get just this:

qDebug() << link << url;
"http://steamcommunity.com/market/listings/730/%E2%98%85%20Gut%20Knife%20%7C%20Safari%20Mesh%20%28Battle-Scarred%29"
QUrl ("") 

Using TolerantMode in QUrl I get just empty page after the query.
So, QUrl considers my link is incorrect. How should I do that query? Thanks.


Solution

  • Try:

    QUrl url = QUrl::fromEncoded(link.toUtf8());
    qDebug() << url;
    

    The output is:

    QUrl( "http://steamcommunity.com/market/listings/730/★ Gut Knife | Safari Mesh (Battle-Scarred)" )