/* Copying and distribution of this file, with or without modification,
 * are permitted in any medium without royalty provided the copyright
 * notice and this notice are preserved.  This file is offered as-is,
 * without any warranty.
 */

module net_sample;

import std.stdio;
import std.range;

import amalthea.net;

void main() {
    auto urls = [
        "https://dlang.org",
        "https://habr.com/ru/articles/352950/",
    ];
    foreach(url; urls) {
        try {
            string title = getHTMLPageTitle(url);
            writeln("URL:     ", url);
            writeln("Title:   ", title);
            auto charset = getCharset(url);
            writeln("Charset: ", charset.empty ? "(unknown)" : charset);
            writeln("-");
        } catch (Exception e) {
            writeln("Error with ", url);
            writeln(e.msg);
            writeln("-");
        }
    }
}
