chore: update dependencies
This commit is contained in:
parent
d5f699054f
commit
03ad1075ab
11
Cargo.toml
11
Cargo.toml
|
@ -1,15 +1,16 @@
|
|||
[package]
|
||||
name = "lodestone_scraper"
|
||||
version = "0.1.0"
|
||||
authors = ["Kyle Clemens <git@kyleclemens.com>"]
|
||||
authors = ["Anna Clemens <git@annaclemens.io>"]
|
||||
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
reqwest = "0.9"
|
||||
reqwest = "0.10"
|
||||
failure = "0.1"
|
||||
# futures = "0.3"
|
||||
lazy_static = "1"
|
||||
url = "1"
|
||||
url = "2"
|
||||
|
||||
[dependencies.lodestone_parser]
|
||||
git = "https://github.com/jkcclemens/lodestone_parser"
|
||||
|
@ -18,3 +19,7 @@ git = "https://github.com/jkcclemens/lodestone_parser"
|
|||
version = "1"
|
||||
default-features = false
|
||||
features = ["worlds", "data_centers", "races", "clans"]
|
||||
|
||||
[dependencies.tokio]
|
||||
version = "0.2"
|
||||
features = ["rt-core", "rt-threaded", "macros"]
|
||||
|
|
|
@ -93,8 +93,8 @@ impl<'a> CharacterSearchBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn send(&self) -> Result<Paginated<CharacterSearchItem>> {
|
||||
let text = self.scraper.text(self.as_url())?;
|
||||
pub async fn send(&self) -> Result<Paginated<CharacterSearchItem>> {
|
||||
let text = self.scraper.text(self.as_url()).await?;
|
||||
lodestone_parser::parse_character_search(&text).map_err(Error::Parse)
|
||||
}
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ impl<'a> FreeCompanySearchBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn send(&self) -> Result<Paginated<FreeCompanySearchItem>> {
|
||||
let text = self.scraper.text(self.as_url())?;
|
||||
pub async fn send(&self) -> Result<Paginated<FreeCompanySearchItem>> {
|
||||
let text = self.scraper.text(self.as_url()).await?;
|
||||
lodestone_parser::parse_free_company_search(&text).map_err(Error::Parse)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ impl<'a> LinkshellBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn send(&self) -> Result<Linkshell> {
|
||||
let text = self.scraper.text(self.as_url())?;
|
||||
pub async fn send(&self) -> Result<Linkshell> {
|
||||
let text = self.scraper.text(self.as_url()).await?;
|
||||
lodestone_parser::parse_linkshell(self.id, &text).map_err(Error::Parse)
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ impl<'a> LinkshellSearchBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn send(&self) -> Result<Paginated<LinkshellSearchItem>> {
|
||||
let text = self.scraper.text(self.as_url())?;
|
||||
pub async fn send(&self) -> Result<Paginated<LinkshellSearchItem>> {
|
||||
let text = self.scraper.text(self.as_url()).await?;
|
||||
lodestone_parser::parse_linkshell_search(&text).map_err(Error::Parse)
|
||||
}
|
||||
|
||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -43,10 +43,11 @@ impl LodestoneScraper {
|
|||
LODESTONE_URL.join(s).map_err(Error::Url)
|
||||
}
|
||||
|
||||
crate fn text(&self, url: Url) -> Result<String> {
|
||||
let mut res = self.client
|
||||
crate async fn text(&self, url: Url) -> Result<String> {
|
||||
let res = self.client
|
||||
.get(url)
|
||||
.send()
|
||||
.await
|
||||
.map_err(Error::Net)?;
|
||||
match res.status() {
|
||||
StatusCode::OK => {},
|
||||
|
@ -55,12 +56,13 @@ impl LodestoneScraper {
|
|||
}
|
||||
res
|
||||
.text()
|
||||
.await
|
||||
.map_err(Error::Net)
|
||||
}
|
||||
|
||||
pub fn character(&self, id: u64) -> Result<Character> {
|
||||
pub async fn character(&self, id: u64) -> Result<Character> {
|
||||
let url = LodestoneScraper::route(&format!("character/{}", id))?;
|
||||
let text = self.text(url)?;
|
||||
let text = self.text(url).await?;
|
||||
lodestone_parser::parse_character(id, &text).map_err(Error::Parse)
|
||||
}
|
||||
|
||||
|
@ -68,9 +70,9 @@ impl LodestoneScraper {
|
|||
builder::CharacterSearchBuilder::new(self)
|
||||
}
|
||||
|
||||
pub fn free_company(&self, id: u64) -> Result<FreeCompany> {
|
||||
pub async fn free_company(&self, id: u64) -> Result<FreeCompany> {
|
||||
let url = LodestoneScraper::route(&format!("freecompany/{}", id))?;
|
||||
let text = self.text(url)?;
|
||||
let text = self.text(url).await?;
|
||||
lodestone_parser::parse_free_company(id, &text).map_err(Error::Parse)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue