Simple crate to login to Pinterest and get the cookies via Chromiumoxide to simulate a browser (open a real browser actually), to use the Pinterest API without needing a developer account or an API key or anything that costs money :).
Asynchronous, and uses async-std as the runtime by default (you can use tokio if you want)
async-std runtime```rust use pinterestlogin::configbuilder::DefaultBrowserConfigBuilder; use pinterestlogin::login; use pinterestlogin::login_bot::DefaultBrowserLoginBot;
async fn main() { let email = std::env::var("PINTERESTEMAIL").unwrap(); let password = std::env::var("PINTERESTPASSWORD").unwrap();
let bot = DefaultBrowserLoginBot::new(email.as_str(), password.as_str());
let config_builder = DefaultBrowserConfigBuilder::default();
match login(&bot, &config_builder).await {
Ok(cookies) => {
// Store the cookies in a file or something, and do whatever you want with them
// I like the cookies bay the way
// ...
println!("{}", cookies.len());
println!("{:?}", cookies);
}
Err(e) => {
// The login was unsuccessful
eprintln!("The login was unsuccessful: {}", e);
}
};
}
rust
use pinterestlogin::configbuilder::DefaultBrowserConfigBuilder;
use pinterestlogin::login;
use pinterestlogin::login_bot::DefaultBrowserLoginBot;
use std::time::Duration;
async fn main() { let email = std::env::var("PINTERESTEMAIL").unwrap(); let password = std::env::var("PINTERESTPASSWORD").unwrap();
let bot = DefaultBrowserLoginBot::new(email.as_str(), password.as_str());
// Show the browser, and set the request timeout to 2 seconds let configbuilder = DefaultBrowserConfigBuilder::new(false, Duration::fromsecs(2).into(), None);
match login(&bot, &config_builder).await {
Ok(cookies) => {
// ...
}
Err(e) => {
// The login was unsuccessful
eprintln!("The login was unsuccessful: {}", e);
}
};
} ```
tokio runtime```rust use pinterestlogin::configbuilder::DefaultBrowserConfigBuilder; use pinterestlogin::login; use pinterestlogin::login_bot::DefaultBrowserLoginBot; use std::time::Duration;
async fn main() { let email = std::env::var("PINTERESTEMAIL").unwrap(); let password = std::env::var("PINTERESTPASSWORD").unwrap();
let bot = DefaultBrowserLoginBot::new(email.asstr(), password.asstr());
// Show the browser, and set the request timeout to 2 seconds let configbuilder = DefaultBrowserConfigBuilder::new(false, Duration::fromsecs(2).into(), None);
match login(&bot, &config_builder).await {
Ok(cookies) => {
// ...
}
Err(e) => {
// The login was unsuccessful
eprintln!("The login was unsuccessful: {}", e);
}
};
} ```
async-std-runtime: Use the async-std runtime instead of tokio (enabled by default)tokio-runtime: Use the tokio runtime instead of async-stddebug: Enable debug loggingI'm happy to accept any contributions, just consider reading the CONTRIBUTING.md guide first. to avoid waste waste our time on some unnecessary things.
the main keywords are: signed commits, conventional commits, no emojis, linear history, the PR shouldn't have more than tree commits most of the time
This project is licensed under ether the MIT license or the Unlicense license, you can choose which one you want.
This project is part of the pinterest-rs project
License: MIT OR Unlicense