113 lines
2.7 KiB
C++
113 lines
2.7 KiB
C++
#ifndef SNAVERBLOG
|
|
#define SNAVERBLOG
|
|
|
|
#include <QObject>
|
|
#include "sutilclass.h"
|
|
#include <QNetworkRequest>
|
|
#include <QMutex>
|
|
#include "swebpage.h"
|
|
|
|
|
|
enum class E_CRAWL_MODE
|
|
{
|
|
BODY = 0,
|
|
REPLY
|
|
};
|
|
|
|
static const QString scriptArticleDate;
|
|
static const QString scriptArticleTitle;
|
|
static const QString scriptArticleData;
|
|
static const QString scriptReplyUrl;
|
|
static const QString scriptArticleNickname;
|
|
static const QString scriptArticleOrder;
|
|
|
|
enum E_FUNC
|
|
{
|
|
E_FUNC_ARTICLE_TITLE = 0,
|
|
E_FUNC_ARTICLE_DATE,
|
|
E_FUNC_ARTICLE_NICKNAME,
|
|
E_FUNC_ARTICLE_ORDER,
|
|
E_FUNC_ARTICLE_DATA,
|
|
E_FUNC_REPLY_URL,
|
|
E_FUNC_MAX
|
|
};
|
|
|
|
class SNaverBlog: public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SNaverBlog(std::shared_ptr<SWebPage> _page = nullptr);
|
|
void go(const QString& _url, E_CRAWL_MODE _mode = E_CRAWL_MODE::BODY);
|
|
|
|
private:
|
|
QString makeReplyUrl(const QString& _url);
|
|
QString changeUrl(const QString& _url);
|
|
void initConnect();
|
|
bool check(const DataForm& _data);
|
|
bool check(const QVector<DataForm>& _data);
|
|
void goReplyUrl();
|
|
|
|
/*
|
|
DataForm getBody();
|
|
QVector<DataForm> getReply();
|
|
void getBody(QWebFrame* frame, DataForm& _data);
|
|
*/
|
|
|
|
signals:
|
|
void signalDataOk(const EffectData& _data);
|
|
void signalError(E_ERROR_CODE _error, const QString& _msg);
|
|
|
|
|
|
public slots:
|
|
void slotLoadFinished(bool ok = true);
|
|
|
|
private slots:
|
|
void slotAlert(const QString& msg);
|
|
|
|
private:
|
|
void cbBodyArticleDate(const QVariant& _result);
|
|
void cbBodyArticleData(const QVariant& _result);
|
|
void cbBodyArticleTitle(const QVariant& _result);
|
|
void cbBodyArticleNickname(const QVariant& result);
|
|
void cbBodyArticleOrder(const QVariant& result);
|
|
void cbBodyReplyUrl(const QVariant& _result);
|
|
void cbBodyLikeCount(const QVariant& _result);
|
|
bool doneBodyCrawler(E_FUNC _func_type);
|
|
|
|
|
|
static const QString scriptArticleDate;
|
|
static const QString scriptArticleTitle;
|
|
static const QString scriptArticleData;
|
|
static const QString scriptReplyUrl;
|
|
static const QString scriptLikeCount;
|
|
static const QString scriptArticleNickname;
|
|
static const QString scriptArticleOrder;
|
|
bool m_abOk[E_FUNC_MAX];
|
|
|
|
void cbReply(const QVariant& _result);
|
|
static const QString scriptReply;
|
|
|
|
|
|
private:
|
|
std::shared_ptr<SWebPage> m_pWebPage;
|
|
std::unique_ptr<QNetworkRequest> m_pNetworkRequest;
|
|
E_CRAWL_MODE m_eMode;
|
|
bool m_bReplyProcessed;
|
|
|
|
bool m_bBodyProcessed;
|
|
QMutex m_mutexBody;
|
|
QMutex m_mutexReply;
|
|
/*
|
|
bool m_bBodyProcessing;
|
|
bool m_bReplyProcessing;
|
|
*/
|
|
EffectData m_efData;
|
|
QString m_strUrl;
|
|
int m_nBodyRetry;
|
|
|
|
};
|
|
|
|
#endif // SNAVERBLOG
|
|
|