最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

rust - How to get cookies from the page that was created by headless_chrome crate with proxy that has authentication? - Stack Ov

programmeradmin0浏览0评论
let proxy = format!("http://{}:{}", "host", "port");
let launch_options = LaunchOptions::default_builder()
    .path(Some(browser::default_executable().unwrap()))
    .proxy_server(Some(&proxy))
    .build()
    .unwrap();
let browser = Browser::new(launch_options).expect("Failed to launch browser");

let tab = browser.new_tab().unwrap();
tab.wait_until_navigated().unwrap();

tab.enable_fetch(None, Some(true)).unwrap()
    .authenticate(Some("username".to_string()), Some("password".to_string())).unwrap()
    .navigate_to("/?src=header&redirect_to=%2F").unwrap()
    .wait_until_navigated().unwrap();

The above code is to launch new browser and new tab that have proxy with authentication. After loading page, I tried to get the cookies using let cookies = tab.call_method(GetAllCookies(Default::default())).expect("Error getting cookies");, but it shows the error: invalid type: map, expected a string How to fix this problem?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论