How to reuse a virtual browser profile (persistent browsing)?

  • Created

We recommend that you read the Getting started with Kameleo Automation article before reading this one.

Using the same browsing context as before, such as your browsing history, cookies, passwords, and session data, can make your job easier by letting websites think you’re a returning user and not a bot.

Save yourself the trouble of having to log in every time you want to use one of your online accounts. Just stay logged in all the time and save the virtual browser profile into a .kameleo file. These files can easily be transferred to any other Kameleo user and you can continue working in the “same browser” by loading back the same .kameleo file.

It is advisable to save virtual browser profiles after each use, since exiting the CLI component will cause it to lose all profiles not saved.

  • await client.stopProfile(profile.id);
    await client.saveProfile(profile.id, { body: { path: `${__dirname}\\test.kameleo` } });
    await client.deleteProfile(profile.id);
    profile = await client.loadProfile({ body: { path: `${__dirname}\\test.kameleo` } });
    await client.startProfile(profile.id);

    See the full example here.

  • await client.StopProfileAsync(profile.Id);
    await client.SaveProfileAsync(profile.Id, new SaveProfileRequest(Path.Combine(Environment.CurrentDirectory,"test.kameleo")));
    await client.DeleteProfileAsync(profile.Id);
    profile = await client.LoadProfileAsync(new LoadProfileRequest(Path.Combine(Environment.CurrentDirectory, "test.kameleo")));
    await client.StartProfileAsync(profile.Id);

    See the full example here.

  • import os
    
    client.stop_profile(profile.id)
    path = f'{os.path.dirname(os.path.realpath(__file__))}\\test.kameleo'
    client.save_profile(profile.id, body=SaveProfileRequest(path=path))
    client.delete_profile(profile.id);
    profile = client.load_profile(body=LoadProfileRequest(path=path))
    client.start_profile(profile.id)

    See the full example here.

Was this article helpful?

0 out of 0 found this helpful