daijro / browserforge

🎭 Intelligent browser header & fingerprint generator
https://pypi.org/project/browserforge
Apache License 2.0
196 stars 13 forks source link

Making a separate browserforge-injector package #7

Open daijro opened 5 months ago

daijro commented 5 months ago

I'm considering separating the the browserforge.injectors submodule into an independently updated browserforge-injector library on pypi in order to:

  1. Make the injector submodules and dependencies optional to those who do not use BrowserForge for controlled browsing
  2. Focus on more advanced integration of Playwright/Pyppeteer fingerprinting workarounds that may be out of scope of the base browserforge package
  3. Make the base browserforge package lighter

Does anyone have any thoughts on this? Let me know!

Ehsan-U commented 2 months ago

@daijro is it possible to inject generated fingerprint into hrequests or requests

daijro commented 2 months ago

@daijro is it possible to inject generated fingerprint into hrequests or requests

Hi, BrowserForge headers can be easily set to a requests session (see here).

Here are some examples:

Using Requests

import requests
from browserforge.headers import HeaderGenerator
# Create the header generator
headers = HeaderGenerator()
# Build the requests session
session = requests.Session()
session.headers = headers.generate()  # Set the session headers
# Send a request
resp = session.get('https://example.com')
print(resp.status_code)

If you're using Requests, you might also want to look into using Hazetunnel to spoof the TLS fingerprint to match the User-Agent browser like hrequests does.

Using Hrequests

import hrequests
from browserforge.headers import HeaderGenerator
# Create a chrome header generator
headers = HeaderGenerator(browser='chrome')
# Build a chrome hrequests session
session = hrequests.Session(browser='chrome')
session.headers = headers.generate()  # Set the session headers
# Send a request
resp = session.get('https://example.com')
print(resp.status_code)

Note: Browserforge will be integrated into hrequests in an upcoming update.