Persistent Fingerprints Using Files
Hi, I need to save the generated fingerprint to a file such that I could load it back later to the browser. Is there a way to dump and load the fingerprint to/from a file?
thanks.
The code written like this is invalid.
if os.path.exists(fingerprint_path):
with open(fingerprint_path, 'r', encoding='utf-8') as f:
data = json.load(f)
fingerprint = Fingerprint(
screen=ScreenFingerprint(**data['screen']),
navigator=NavigatorFingerprint(**data['navigator']),
headers=data['headers'],
videoCodecs=data['videoCodecs'],
audioCodecs=data['audioCodecs'],
pluginsData=data['pluginsData'],
battery=data['battery'],
videoCard=VideoCard(**data['videoCard']) if data.get('videoCard') else None,
multimediaDevices=data['multimediaDevices'],
fonts=data['fonts'],
mockWebRTC=data.get('mockWebRTC', False),
slim=data.get('slim', False)
)
else:
fingerprint = fg.generate()
fingerprint_dict = json.loads(fingerprint.dumps())
with open(fingerprint_path, 'w', encoding='utf-8') as f:
json.dump(fingerprint_dict, f, ensure_ascii=False, indent=4)
you can use pickle.dump and pickle.load
json dump does not support dataclass
https://github.com/daijro/browserforge/pull/35
@techinz Hey. Thanks for the pr. correct me if I'm wrong, but when load up creepjs , it keeps rotating different FP ID, albeit with the same device type. When using regular chromium, that ID remains the same.
edit: It seems like if one is using camoufox, many browserforge attributes will simply be ignored, and swapped out with a random value
fingerprint (Optional [Fingerprint]):
Use a custom BrowserForge fingerprint. Note: Not all values will be implemented.
If not provided, a random fingerprint will be generated based on the provided
`os&s os & screen constraints.
@techinz Hey. Thanks for the pr. correct me if I'm wrong, but when load up creepjs , it keeps rotating different FP ID, albeit with the same device type. When using regular chromium, that ID remains the same.
edit: It seems like if one is using camoufox, many browserforge attributes will simply be ignored, and swapped out with a random value
fingerprint (Optional [Fingerprint]): Use a custom BrowserForge fingerprint. Note: Not all values will be implemented. If not provided, a random fingerprint will be generated based on the provided `os&s os & screen constraints.
Yeah, later I noticed that it works weird and I found some other way to persist fingerprints. I think there is no good way to do it atm.
@techinz Vlad, share please your experience on how you managed to achieve a persist fingerprints. I am also looking for a solution.
@techinz Vlad, share please your experience on how you managed to achieve a persist fingerprints. I am also looking for a solution.
I don't really remember and not sure if it worked, but it was something like that:
fingerprint_file = os.path.join(user_data_path, "fingerprint.json")
if os.path.exists(fingerprint_file):
opts = json.load(open(fingerprint_file))
else:
opts = launch_options(headless=...,
proxy=...,
geoip=True,
user_data_dir=user_data_path
)
json.dump(opts, open(fingerprint_file, "w"), indent=2)
camoufox = AsyncCamoufox(
persistent_context=True,
from_options=opts,
i_know_what_im_doing=True
)
@techinz I know this)) I am about of content of fingerprint.json. I am looking for parameters example.