mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 18:24:10 +02:00
clippy
This commit is contained in:
parent
da91e0592d
commit
5e034d7bef
2 changed files with 6 additions and 17 deletions
12
src/lib.rs
12
src/lib.rs
|
|
@ -55,7 +55,7 @@ impl UgcClient {
|
|||
pub async fn player(&self, steam_id: SteamID) -> Result<Player> {
|
||||
let res = self
|
||||
.client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"https://www.ugcleague.com/players_page.cfm?player_id={}",
|
||||
u64::from(steam_id)
|
||||
))
|
||||
|
|
@ -72,7 +72,7 @@ impl UgcClient {
|
|||
pub async fn player_team_history(&self, steam_id: SteamID) -> Result<Vec<MembershipHistory>> {
|
||||
let res = self
|
||||
.client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"https://www.ugcleague.com/players_page_details.cfm?player_id={}",
|
||||
u64::from(steam_id)
|
||||
))
|
||||
|
|
@ -89,7 +89,7 @@ impl UgcClient {
|
|||
pub async fn team(&self, id: u32) -> Result<Team> {
|
||||
let body = self
|
||||
.client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"https://www.ugcleague.com/team_page.cfm?clan_id={}",
|
||||
id
|
||||
))
|
||||
|
|
@ -104,7 +104,7 @@ impl UgcClient {
|
|||
pub async fn team_roster_history(&self, id: u32) -> Result<TeamRosterData> {
|
||||
let body = self
|
||||
.client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"https://www.ugcleague.com/team_page_rosterhistory.cfm?clan_id={}",
|
||||
id
|
||||
))
|
||||
|
|
@ -119,7 +119,7 @@ impl UgcClient {
|
|||
pub async fn team_matches(&self, id: u32) -> Result<Vec<TeamSeason>> {
|
||||
let body = self
|
||||
.client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"https://www.ugcleague.com/team_page_matches.cfm?clan_id={}",
|
||||
id
|
||||
))
|
||||
|
|
@ -155,7 +155,7 @@ impl UgcClient {
|
|||
pub async fn match_info(&self, id: u32) -> Result<MatchInfo> {
|
||||
let body = self
|
||||
.client
|
||||
.get(&format!(
|
||||
.get(format!(
|
||||
"https://www.ugcleague.com/matchpage_tf2h.cfm?mid={}",
|
||||
id
|
||||
))
|
||||
|
|
|
|||
|
|
@ -33,23 +33,12 @@ pub trait Parser {
|
|||
|
||||
trait ElementExt<'a> {
|
||||
fn first_text(&self) -> Option<&'a str>;
|
||||
fn nth_text(&self, n: usize) -> Option<&'a str>;
|
||||
fn last_text(&self) -> Option<&'a str>;
|
||||
}
|
||||
|
||||
impl<'a> ElementExt<'a> for ElementRef<'a> {
|
||||
fn first_text(&self) -> Option<&'a str> {
|
||||
self.text().map(str::trim).find(|s| !s.is_empty())
|
||||
}
|
||||
fn nth_text(&self, n: usize) -> Option<&'a str> {
|
||||
self.text()
|
||||
.filter(|s| !s.trim().is_empty())
|
||||
.nth(n - 1)
|
||||
.map(str::trim)
|
||||
}
|
||||
fn last_text(&self) -> Option<&'a str> {
|
||||
self.text().map(str::trim).filter(|s| !s.is_empty()).last()
|
||||
}
|
||||
}
|
||||
|
||||
fn select_text<'a>(el: ElementRef<'a>, selector: &Selector) -> Option<&'a str> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue