chore(renamed): removed froxy prefix on folders
This commit is contained in:
parent
e57bb34a35
commit
6960959794
29 changed files with 32 additions and 12 deletions
27
scraper/examples/get_friends.rs
Normal file
27
scraper/examples/get_friends.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use froxy_scrapper::{state::State, types::ClusterLocation};
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let session = std::env::var("FROXY_COOKIE")
|
||||
.expect("provide `FROXY_COOKIE` with the session cookie from you friends42 instance");
|
||||
let state = State::new(session);
|
||||
|
||||
let res = state.get("/friends/", None).await.unwrap();
|
||||
|
||||
let text = res.text().await.unwrap();
|
||||
|
||||
let location = froxy_scrapper::parsing::friend_page(&text);
|
||||
|
||||
for l in &location.friends {
|
||||
println!(
|
||||
"{:^10} | {:^10} | {:^30} | {:^20}",
|
||||
l.login,
|
||||
l.position.as_ref().map(|s| s.as_str()).unwrap_or("<>"),
|
||||
l.last_active.as_ref().map(|s| s.as_str()).unwrap_or("<>"),
|
||||
l.image
|
||||
.as_ref()
|
||||
.map(|s| &s[s.len().saturating_sub(20)..])
|
||||
.unwrap_or("<>")
|
||||
);
|
||||
}
|
||||
}
|
||||
37
scraper/examples/get_frontpage.rs
Normal file
37
scraper/examples/get_frontpage.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
use froxy_scrapper::{state::State, types::ClusterLocation};
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let session = std::env::var("FROXY_COOKIE")
|
||||
.expect("provide `FROXY_COOKIE` with the session cookie from you friends42 instance");
|
||||
let state = State::new(session);
|
||||
|
||||
let res = state.get("/", Some("cluster=f4")).await.unwrap();
|
||||
|
||||
let text = res.text().await.unwrap();
|
||||
|
||||
let location = froxy_scrapper::parsing::get_cluster_location("F4", &text);
|
||||
|
||||
for l in &location.locations {
|
||||
match &l.data {
|
||||
froxy_scrapper::types::ClusterLocationData::Empty => {}
|
||||
froxy_scrapper::types::ClusterLocationData::User {
|
||||
login,
|
||||
image,
|
||||
relation,
|
||||
} => {
|
||||
eprintln!(
|
||||
"[{:<10}] {login:<10} {relation:?} {}",
|
||||
l.location,
|
||||
image
|
||||
.as_ref()
|
||||
.map(|i| i.to_string())
|
||||
.unwrap_or_else(|| "NO IMAGE".to_string())
|
||||
)
|
||||
}
|
||||
froxy_scrapper::types::ClusterLocationData::Normal { status } => {
|
||||
// eprintln!("[{:<10}] {status:?}", l.location)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
scraper/examples/get_user.rs
Normal file
14
scraper/examples/get_user.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use froxy_scrapper::{state::State, types::ClusterLocation};
|
||||
|
||||
#[tokio::main(flavor = "current_thread")]
|
||||
async fn main() {
|
||||
let session = std::env::var("FROXY_COOKIE")
|
||||
.expect("provide `FROXY_COOKIE` with the session cookie from you friends42 instance");
|
||||
let state = State::new(session);
|
||||
|
||||
for a in std::env::args().skip(1) {
|
||||
let res = state.getuser(&a).await.unwrap();
|
||||
serde_json::to_writer_pretty(&mut std::io::stdout(), &res).unwrap();
|
||||
println!();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue