Compare commits
No commits in common. "1e09947b68b8a4b351260a076cac66e04ac995be" and "6dc1fb616f9ef084ab5067e2fbdaa90d9f043309" have entirely different histories.
1e09947b68
...
6dc1fb616f
3 changed files with 1 additions and 70 deletions
27
Cargo.lock
generated
27
Cargo.lock
generated
|
@ -2,15 +2,6 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "0.7.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -51,7 +42,6 @@ checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db"
|
||||||
name = "cal8tor"
|
name = "cal8tor"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"regex",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"scraper",
|
"scraper",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -903,23 +893,6 @@ dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex"
|
|
||||||
version = "1.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
|
||||||
dependencies = [
|
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "regex-syntax"
|
|
||||||
version = "0.6.27"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "remove_dir_all"
|
name = "remove_dir_all"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
|
|
|
@ -9,4 +9,3 @@ edition = "2021"
|
||||||
reqwest = { version = "0.11" }
|
reqwest = { version = "0.11" }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
scraper = "0.13.0"
|
scraper = "0.13.0"
|
||||||
regex = "1"
|
|
||||||
|
|
43
src/info.rs
43
src/info.rs
|
@ -1,4 +1,3 @@
|
||||||
use regex::Regex;
|
|
||||||
use scraper::{Html, Selector};
|
use scraper::{Html, Selector};
|
||||||
|
|
||||||
pub async fn info() {
|
pub async fn info() {
|
||||||
|
@ -6,53 +5,13 @@ pub async fn info() {
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
let sel_ul = Selector::parse("ul").unwrap();
|
let sel_ul = Selector::parse("ul").unwrap();
|
||||||
let sel_li = Selector::parse("li").unwrap();
|
|
||||||
|
|
||||||
// Find the raw infos in html page
|
// Find the raw infos in html page
|
||||||
let mut raw_data = Vec::new();
|
|
||||||
for (i, data) in document.select(&sel_ul).enumerate() {
|
for (i, data) in document.select(&sel_ul).enumerate() {
|
||||||
if [1, 2].contains(&i) {
|
if [1, 2].contains(&i) {
|
||||||
raw_data.push(data);
|
println!("\n{} - {:#?}", data.value().name(), data.inner_html());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut data = std::collections::HashMap::new();
|
|
||||||
// d => date
|
|
||||||
// r => repetition
|
|
||||||
let re = Regex::new(r"(?P<d>\d{1,2} \w+ \d{4}).+(?P<r>\d)").unwrap();
|
|
||||||
for (i, ul) in raw_data.into_iter().enumerate() {
|
|
||||||
for element in ul.select(&sel_li) {
|
|
||||||
match element.inner_html() {
|
|
||||||
e if e.starts_with("Début") => {
|
|
||||||
let captures = re.captures(&e).unwrap();
|
|
||||||
data.insert(
|
|
||||||
i,
|
|
||||||
format!(
|
|
||||||
"{} pendant {}s",
|
|
||||||
captures.name("d").unwrap().as_str(),
|
|
||||||
captures.name("r").unwrap().as_str()
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
e if e.starts_with("Reprise") => {
|
|
||||||
let captures = re.captures(&e).unwrap();
|
|
||||||
captures.name("g");
|
|
||||||
data.insert(
|
|
||||||
i,
|
|
||||||
format!(
|
|
||||||
"{} puis reprise {} pendant {}s",
|
|
||||||
data.get(&i).unwrap(),
|
|
||||||
captures.name("d").unwrap().as_str(),
|
|
||||||
captures.name("r").unwrap().as_str()
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
println!("{:#?}", data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_webpage() -> Result<Html, Box<dyn std::error::Error>> {
|
async fn get_webpage() -> Result<Html, Box<dyn std::error::Error>> {
|
||||||
|
|
Reference in a new issue