QUrl can't parse some web urls
-
QString url = "https://lichess.org/Mq8MR9ri"; QNetworkAccessManager manager; QNetworkReply* response = manager.get(QNetworkRequest(QUrl(url))); QEventLoop event; QObject::connect(response, SIGNAL(finished()), &event, SLOT(quit())); event.exec(); QString content = response->readAll(); qInfo() << content;
this is my code, it works fine for some link, but for some links, not.
for example : QString url = "https://lichess.org/vAArADOV3ege";
response->url().host(); returns wrong path... -
@Harry56
Hello and welcome.Purely a guess. When I paste your first working URL, https://lichess.org/Mq8MR9ri, into Chrome it takes me to that exact URL. But when I paste your second non-working URL, https://lichess.org/vAArADOV3ege, it seems to redirect me to https://lichess.org/vAArADOV/black. Is this significant?
-
QString url = "https://lichess.org/vAArADOV3ege";
QNetworkAccessManager manager;
manager.setRedirectPolicy(QNetworkRequest::SameOriginRedirectPolicy);
QNetworkReply* response = manager.get(QNetworkRequest(QUrl(url)));
QEventLoop event;
QObject::connect(response, SIGNAL(finished()), &event, SLOT(quit()));
event.exec();qInfo() << response->errorString();
"Host not found."
@JonB said in QUrl can't parse some web urls:
@Harry56
Hello and welcome.Purely a guess. When I paste your first working URL, https://lichess.org/Mq8MR9ri, into Chrome, it takes me to that exact URL. But when I paste your second non-working URL, https://lichess.org/vAArADOV3ege, it seems to redirect me to https://lichess.org/vAArADOV/black. Is this significant?
Yes, https://lichess.org/vAArADOV/black works, but why does redirect not works?
Thanks for answering