#ifndef SCRAWLER_H
#define SCRAWLER_H

#include <QWebPage>
#include <QObject>
#include <QThreadPool>

#include "sreplygetmanage.h"

class SCrawler : public QObject
{
    Q_OBJECT    
public:
    explicit SCrawler(QObject *parent = 0);
    ~SCrawler();
    void load(QStringList _strlistArgv);
    void Debug(QString _strFilename,QString _strData);    
signals:
    void finished();
private slots:
    void saveResult(bool ok);
private:
    QWebPage *m_page;    
    QString m_strUrl;
    SReplyGetManage m_reply;
    SCrawlerData m_data;
    bool m_bUse;    
private:
    QWebElement Find(const QWebElement _FindElement,const QString _strElement,const QString _strAttrib,const QString _strFind);
    QWebElement FindMid(const QWebElement _FindElement,const QString _strElement,const QString _strAttrib,const QString _strFind, const int _strStart);
    QWebElement FindLeft(const QWebElement _FindElement,const QString _strElement,const QString _strAttrib,const QString _strFind);
    QWebElement FindMid(const QWebElement _FindElement,const QString _strElement,const QString _strAttrib,const QString _strFind, const int _strStart, const int _strLength);
    QList<QWebElement> FindAllMid(const QWebElement _FindElement,const QString _strElement,const QString _strAttrib,const QString _strFind, const int _strStart, const int _strLength);

    void saveFrameNaverNews(QWebFrame *frame);
    void saveResultNaverNews();
    void saveFrameDaumCafe(QWebFrame *frame);
    void saveResultDaumCafe();
};

#endif // SCRAWLER_H
