forked from cpp-netlib/cpp-netlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (30 loc) · 1.01 KB
/
Copy pathmain.cpp
File metadata and controls
36 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) Glyn Matthews 2011.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "rss.hpp"
#include <boost/network/protocol/http/client.hpp>
#include <iostream>
int main(int argc, char *argv[]) {
using namespace boost::network;
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " <url>" << std::endl;
return 1;
}
try {
http::client client;
http::client::request request(argv[1]);
request << header("Connection", "close");
http::client::response response = client.get(request);
rss::channel channel(response);
std::cout << "Channel: " << channel.title() << " (" << channel.description()
<< ")" << std::endl;
for (const rss::item & item : channel) {
std::cout << item.title() << " (" << item.author() << ")" << std::endl;
}
}
catch (std::exception &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}