fix ms datasource
This commit is contained in:
parent
16947d2734
commit
34d50b419d
1 changed files with 6 additions and 3 deletions
|
@ -7,7 +7,10 @@ use crate::Champion;
|
|||
|
||||
pub struct MSDataSource;
|
||||
|
||||
const CHAMP_PATTERN: &str = " href=\"https://www.metasrc.com/5v5/champion/";
|
||||
|
||||
impl DataSource for MSDataSource {
|
||||
|
||||
fn get_alias(&self) -> &str {
|
||||
"MS"
|
||||
}
|
||||
|
@ -30,9 +33,9 @@ impl DataSource for MSDataSource {
|
|||
.into_string()
|
||||
.unwrap();
|
||||
|
||||
let mut pos: Option<usize> = page.find(" href=\"/5v5/champion/");
|
||||
let mut pos: Option<usize> = page.find(CHAMP_PATTERN);
|
||||
while let Some(mut p) = pos {
|
||||
p += 21;
|
||||
p += CHAMP_PATTERN.len();
|
||||
let role =
|
||||
&page[p + page[p..].find('/').unwrap() + 1..p + page[p..].find('"').unwrap()];
|
||||
|
||||
|
@ -44,7 +47,7 @@ impl DataSource for MSDataSource {
|
|||
|
||||
champs.insert(id, vec![role.to_string()]);
|
||||
|
||||
let next = page[p..].find(" href=\"/5v5/champion/");
|
||||
let next = page[p..].find(CHAMP_PATTERN);
|
||||
if let Some(n) = next {
|
||||
pos = Some(p + n);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue