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