diff --git a/dataengines/potd/noaaprovider.h b/dataengines/potd/noaaprovider.h --- a/dataengines/potd/noaaprovider.h +++ b/dataengines/potd/noaaprovider.h @@ -3,10 +3,10 @@ * Copyright 2008 by Anne-Marie Mahfouf * Copyright 2016 Weng Xuetian * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -60,8 +60,7 @@ QImage image() const override; private: - void firstPageRequestFinished(KJob *job); - void secondPageRequestFinished(KJob *job); + void pageRequestFinished(KJob *job); void imageRequestFinished(KJob *job); private: diff --git a/dataengines/potd/noaaprovider.cpp b/dataengines/potd/noaaprovider.cpp --- a/dataengines/potd/noaaprovider.cpp +++ b/dataengines/potd/noaaprovider.cpp @@ -29,10 +29,10 @@ NOAAProvider::NOAAProvider(QObject *parent, const QVariantList &args) : PotdProvider(parent, args) { - const QUrl url(QStringLiteral("http://www.nesdis.noaa.gov/content/imagery-and-data")); + const QUrl url(QStringLiteral("https://www.nesdis.noaa.gov/content/imagery-and-data")); KIO::StoredTransferJob *job = KIO::storedGet(url, KIO::NoReload, KIO::HideProgressInfo); - connect(job, &KIO::StoredTransferJob::finished, this, &NOAAProvider::firstPageRequestFinished); + connect(job, &KIO::StoredTransferJob::finished, this, &NOAAProvider::pageRequestFinished); } NOAAProvider::~NOAAProvider() = default; @@ -42,7 +42,7 @@ return mImage; } -void NOAAProvider::firstPageRequestFinished(KJob* _job) +void NOAAProvider::pageRequestFinished(KJob* _job) { KIO::StoredTransferJob *job = static_cast( _job ); if (job->error()) { @@ -57,50 +57,18 @@ // not be parsed successfully till the content we want. And we do not want // to use heavy weight QtWebkit. So we use QRegularExpression to capture // the wanted url here. - QString url; - QRegularExpression re(QStringLiteral("href=\".*\\/content\\/(.*)\">\"Latest( _job ); - if (job->error()) { - emit error(this); - return; - } - - const QString data = QString::fromUtf8( job->data() ); - - // Using regular expression could be fragile in such case, but the HTML - // NOAA page itself is not a valid XML file and unfortunately it could - // not be parsed successfully till the content we want. And we do not want - // to use heavy weight QtWebkit. So we use QRegularExpression to capture - // the wanted url here. - QString url; - QRegularExpression re(QStringLiteral("a href='(.*)'>