3个不稳定版本
0.2.0-alpha.1 | 2024年3月8日 |
---|---|
0.1.1 | 2023年9月24日 |
0.1.0 | 2023年9月24日 |
在 身份验证 中排名 266
每月下载量 25 次
在 pinterest-rs 中使用
3.5MB
380 行
简单的crate,用于登录Pinterest并通过Chromiumoxide模拟浏览器(实际上打开一个真实的浏览器)来获取cookies,以使用Pinterest API而无需开发者账户、API密钥或任何需要付费的东西 :)。
异步的,默认使用async-std作为运行时(如果需要可以使用tokio)
警告:此项目不是由Pinterest官方支持,也与Pinterest无任何关联。
示例
使用async-std
运行时
use pinterest_login::config_builder::DefaultBrowserConfigBuilder;
use pinterest_login::login;
use pinterest_login::login_bot::DefaultBrowserLoginBot;
#[async_std::main]
async fn main() {
let email = std::env::var("PINTEREST_EMAIL").unwrap();
let password = std::env::var("PINTEREST_PASSWORD").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);
}
};
}
use pinterest_login::config_builder::DefaultBrowserConfigBuilder;
use pinterest_login::login;
use pinterest_login::login_bot::DefaultBrowserLoginBot;
use std::time::Duration;
#[async_std::main]
async fn main() {
let email = std::env::var("PINTEREST_EMAIL").unwrap();
let password = std::env::var("PINTEREST_PASSWORD").unwrap();
let bot = DefaultBrowserLoginBot::new(email.as_str(), password.as_str());
// Show the browser, and set the request timeout to 2 seconds
let config_builder = DefaultBrowserConfigBuilder::new(false, Duration::from_secs(2).into(), None);
match login(&bot, &config_builder).await {
Ok(cookies) => {
// ...
}
Err(e) => {
// The login was unsuccessful
eprintln!("The login was unsuccessful: {}", e);
}
};
}
使用tokio
运行时
use pinterest_login::config_builder::DefaultBrowserConfigBuilder;
use pinterest_login::login;
use pinterest_login::login_bot::DefaultBrowserLoginBot;
use std::time::Duration;
#[tokio::main]
async fn main() {
let email = std::env::var("PINTEREST_EMAIL").unwrap();
let password = std::env::var("PINTEREST_PASSWORD").unwrap();
let bot = DefaultBrowserLoginBot::new(email.as_str(), password.as_str());
// Show the browser, and set the request timeout to 2 seconds
let config_builder = DefaultBrowserConfigBuilder::new(false, Duration::from_secs(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
:使用async-std运行时而不是tokio(默认启用)tokio-runtime
:使用tokio运行时而不是async-stddebug
:启用调试日志
贡献
我很高兴接受任何贡献,但请首先阅读CONTRIBUTING.md指南,以避免在我们的一些不必要的事情上浪费时间。
主要关键词:签名提交,常规提交,无表情符号,线性历史,如果可能尝试合并提交
许可
本项目许可协议为MIT许可或Unlicense许可,您可以选择其中之一。
本项目是pinterest-rs项目的一部分
依赖关系图
依赖
~13–31MB
~495K SLoC