pub fn index() -> Result<Vec<String>, minreq::Error> {
let response = minreq::get("https://www.rfc-editor.org/rfc-index.txt").send()?;
let data = scrape(response.as_str()?);
Ok(data)
}
pub fn rfc(sn: u32) -> Result<String, minreq::Error> {
let address = format!("https://www.rfc-editor.org/rfc/rfc{}.txt", sn);
let response = minreq::get(&address).send()?;
Ok(String::from(response.as_str()?))
}
pub fn scrape(data: &str) -> Vec<String> {
let mut count = 0;
let mut rfcs = vec![];
let mut buff = String::from("");
for line in data.lines() {
if count > 65 {
if line == "" {
rfcs.push(buff);
buff = String::from("");
} else {
buff = format!("{}{}", buff, line);
}
} else {
count += 1;
}
}
rfcs
}