相关疑难解决方法(0)

Python:使用Cookie登录Selenium

我想要做的是打开一个页面(例如youtube)并自动登录,就像我在浏览器中手动打开它一样。

据我了解,我必须使用cookie,问题是我不知道如何使用。

我尝试使用以下方法下载YouTube Cookie:

driver = webdriver.Firefox(executable_path="driver/geckodriver.exe")
driver.get("https://www.youtube.com/")
print(driver.get_cookies())
Run Code Online (Sandbox Code Playgroud)

我得到的是:

{'name':'VISITOR_INFO1_LIVE','value':'EDkAwwhbDKQ','path':'/','domain':'.youtube.com','expiry':None,'secure':False,'httpOnly ':真实}

那我必须加载什么cookie才能自动登录?

python selenium

7
推荐指数
3
解决办法
9544
查看次数

无法使用 Selenium c# 保存 Whatsapp 网络的会话

我想保存 Whatsapp Web 的会话,这样我就不必每次打开 Whatsapp Web 时都扫描二维码。我用:

options.AddArgument("--user-data-dir=" + FolderPathToStoreSession)
Run Code Online (Sandbox Code Playgroud)

但又qr-code出现了。这是第一次打开whatsapp web扫描二维码并将其保存到文件夹的方法:

public static int OpenNewChrome(
        string Website,
        int TimeToWaitInMinutes,
        string FolderPathToStoreSession)
{
    ChromeOptions options = null;
    ChromeDriver driver = null;
    try
    {
        //chrome process id
        int ProcessId = -1;
        //time to wait until open chrome
        var TimeToWait = TimeSpan.FromMinutes(TimeToWaitInMinutes);
        ChromeDriverService cService = ChromeDriverService.CreateDefaultService();
        //hide dos screen
        cService.HideCommandPromptWindow = true;
        options = new ChromeOptions();
        //session file directory
        options.AddArgument("--user-data-dir=" + FolderPathToStoreSession);
        driver = new ChromeDriver(cService, options, TimeToWait);

        //set process …
Run Code Online (Sandbox Code Playgroud)

c# selenium selenium-chromedriver whatsapp

5
推荐指数
1
解决办法
2343
查看次数

标签 统计

selenium ×2

c# ×1

python ×1

selenium-chromedriver ×1

whatsapp ×1