Reusing virtual browser profiles

  • Created

Save yourself the trouble of having to log in every time when you want to use one of your online accounts. Just stay logged in all the time with Kameleo's virtual browser profiles. 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.

Persistent browser context and browser fingerprint data is stored in virtual browser profiles. They are stored in Kameleo's workspace and they can be exported to .kameleo files as well. In this article we are showcasing both option.

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

Reuse profiles from the workspace

It's important to note that these profiles are not saved to .kameleo files but they are not removed from the workspace either (Meaning that they are currently inactive in the workspace folder of Kameleo). 

  • # List all profiles in the workspace
    profiles = client.list_profiles()
    # Iterate over each profile for profile in profiles: if profile.status.lifetime_state == 'terminated' or profile.status.lifetime_state == 'created': # Start the profile client.start_profile(profile.id) # Wait for 5 seconds time.sleep(5) # HERE IS WHERE THE AUTOMATED BROWSING WOULD BE ADDED. # Stop the profile client.stop_profile(profile.id)

Reuse profiles from .kameleo files

If you would like to use the virtual browser profiles on another PC or store backup them, you can export them into a .kameleo file. These files can easily be transferred to any other Kameleo user, and they can continue working in the “same browser” by loading back the same .kameleo file.

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

    See the full example here.

  • await client.StopProfileAsync(profile.Id);
    await client.ExportProfileAsync(profile.Id, new SaveProfileRequest(Path.Combine(Environment.CurrentDirectory,"test.kameleo")));
    await client.DeleteProfileAsync(profile.Id);
    profile = await client.ImportProfileAsync(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.export_profile(profile.id, body=ExportProfileRequest(path=path))
    client.delete_profile(profile.id);
    profile = client.import_profile(body=ImportProfileRequest(path=path))
    client.start_profile(profile.id)

    See the full example here.

Was this article helpful?

0 out of 1 found this helpful