TikTokApi.stealth package
This package is a modified version of playwright_stealth, used to mask the browser as a real browser.
This package is used to prevent TikTok from detecting that you are using a bot.
You probably shouldn’t be interacting with this package directly, but rather through the TikTokApi
class.
Here’s some stealth resources that I always keep forgetting, so I’m putting them here:
Am I Unique? (cool because they split up the distribution of each field, I don’t really use much)
Bot Detection Resources:
TikTokApi.stealth.stealth
- class TikTokApi.stealth.stealth.StealthConfig(webdriver: bool = True, webgl_vendor: bool = True, chrome_app: bool = True, chrome_csi: bool = True, chrome_load_times: bool = True, chrome_runtime: bool = True, iframe_content_window: bool = True, media_codecs: bool = True, navigator_hardware_concurrency: int = 4, navigator_languages: bool = True, navigator_permissions: bool = True, navigator_platform: bool = True, navigator_plugins: bool = True, navigator_user_agent: bool = True, navigator_vendor: bool = True, outerdimensions: bool = True, hairline: bool = True, vendor: str = 'Intel Inc.', renderer: str = 'Intel Iris OpenGL Engine', nav_vendor: str = 'Google Inc.', nav_user_agent: str = None, nav_platform: str = None, languages: Tuple[str] = ('en-US', 'en'), runOnInsecureOrigins: bool | None = None)[source]
Bases:
object
Playwright stealth configuration that applies stealth strategies to playwright page objects. The stealth strategies are contained in ./js package and are basic javascript scripts that are executed on every page.goto() called. .. note:
All init scripts are combined by playwright into one script and then executed this means the scripts should not have conflicting constants/variables etc. ! This also means scripts can be extended by overriding enabled_scripts generator: ``` @property def enabled_scripts(): yield 'console.log("first script")' yield from super().enabled_scripts() yield 'console.log("last script")' ```
- chrome_app: bool = True
- chrome_csi: bool = True
- chrome_load_times: bool = True
- chrome_runtime: bool = True
- property enabled_scripts
- hairline: bool = True
- iframe_content_window: bool = True
- languages: Tuple[str] = ('en-US', 'en')
- media_codecs: bool = True
- outerdimensions: bool = True
- renderer: str = 'Intel Iris OpenGL Engine'
- runOnInsecureOrigins: bool | None = None
- vendor: str = 'Intel Inc.'
- webdriver: bool = True
- webgl_vendor: bool = True
- async TikTokApi.stealth.stealth.stealth_async(page: Page, config: StealthConfig = None)[source]
stealth the page