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
pub mod archive_of_our_own;
pub mod fanfiction;

#[macro_export]
macro_rules! select {
    (string <> $html:expr => $selector:expr) => {
        $html
            .select($selector)
            .next()
            .map(|sd| sd.text().collect::<Vec<_>>().join(""))
            .expect(concat!(
                "HTML is missing the required node for selector: [",
                stringify!($selector),
                "], did the HTML change?"
            ))
    };
    (string[] <> $html:expr => $selector:expr) => {
        $html
            .select($selector)
            .next()
            .map(|sd| sd.text().map(String::from).collect::<Vec<_>>())
            .expect(concat!(
                "HTML is missing the required node for selector: [",
                stringify!($selector),
                "], did the HTML change?"
            ))
    };
}