Test for HTTP status
[dueringa_WikiWalker.git] / src / CurlWikiGrabber.h
blob8aa2c0f558423c672f6e7f3f637c7b6e14414efe
1 #ifndef _CURL_WIKI_GRABBER_H
2 #define _CURL_WIKI_GRABBER_H
4 #include <string>
5 #include <curl/curl.h>
6 #include "WalkerException.h"
7 #include "Article.h"
9 //! Class responsible for grabbing the contents / links of an article
10 class CurlWikiGrabber
12 public:
13 //! Create a new instance.
14 //! Might throw an exception, if curl intialization failed
15 CurlWikiGrabber()
17 int error = curl_global_init(CURL_GLOBAL_ALL);
18 if(error)
20 throw WalkerException("CURL init failed");
24 ~CurlWikiGrabber()
26 curl_global_cleanup();
29 /*! given an URL, return an Article with its links
30 * \returns an Article instance wiith title and links set.
31 * If title is empty, an error occurred.
33 Article grabUrl(std::string url);
36 #endif // _CURL_WIKI_GRABBER_H