I am trying to use Poco to capture news from the first page of reddit. I am looking at this pdf ( http://pocoproject.org/slides/200-Network.pdf ) for an answer, but it is a little over my head at the moment, and I'm not sure how to achieve my goal. As I said, I'm just trying to grab news articles (in particular, article headings) from www.reddit.com.
The code that I still grab ALL of the html from the first page of reddit and display it on the screen:
#include <iostream>
#include "Poco/Net/SocketAddress.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Net/SocketStream.h"
#include "Poco/StreamCopier.h"
using namespace std;
using namespace Poco::Net;
using namespace Poco;
int main(int argc, char *argv[])
{
SocketAddress sa("www.reddit.com", 80);
StreamSocket socket(sa);
SocketStream str(socket);
str << "GET / HTTP/1.1\r\n"
"Host: www.reddit.com\r\n"
"\r\n";
str.flush();
StreamCopier::copyStream(str, cout);
system("PAUSE");
}
Looking at the pdf above, it looks like my answer might be out there somewhere, but I'm still learning about computer networks and the Internet protocol, so most of them are above my head at the moment.
: - , www.reddit.com ?