Skip to content

robo9k/xkcd-rs

Repository files navigation

nix-shell -p rustup openssl jq nodejs sqlite

archive

let urls = [];
document.querySelectorAll('#middleContainer a').forEach(a => {
    urls.push({
		num: a.href.match(/\d+/)[0],
		url: `${a.href}info.0.json`
    });
});
console.debug(JSON.stringify(urls));

comics.json

jq . comics.json > comics-pretty.json

comics-pretty.json

download.js

node download.js

schema.sql insert.sql

sqlite3 comics.db
sqlite> .read schema.sql
sqlite> .read insert.sql

jq -r 'keys | @csv' db/xkcd-1.json && jq -r '[.alt,.day,.img,.link,.month,.news,.num,.safe_title,.title,.transcript,.year] | @csv' db/xkcd-*.json > comics.csv
sqlite3 comics.db
sqlite> .mode csv
sqlite> .import comics.csv comics

comics.csv

use url::Url;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let base = Url::parse("https://xkcd.com")?;
    let url = base.join("//xkcd.com/1506/")?;
    println!("{}", String::from(url));

    Ok(())
}
use http::Uri;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let uri: Uri = "//xkcd.com/1506/".parse()?;
    println!("{}", uri);

    Ok(())
}
. .env
cargo run

About

xkcd tooling in Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published