From be04ae2d36ffdc136e8913a3f949e8e261c69153 Mon Sep 17 00:00:00 2001 From: SoClose <33631880+SoClosee@users.noreply.github.com> Date: Wed, 4 Mar 2026 16:12:11 +0100 Subject: [PATCH] fix(config.py): replace hardcoded user agent with environment variable --- twitter_scraper/config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/twitter_scraper/config.py b/twitter_scraper/config.py index 64f0b7e..4a9de54 100644 --- a/twitter_scraper/config.py +++ b/twitter_scraper/config.py @@ -1,4 +1,6 @@ -"""Configuration constants for TwitterDataScraper.""" +from __future__ import annotations + +import os TWITTER_LOGIN_URL = "https://twitter.com/i/flow/login" TWITTER_BASE_URL = "https://twitter.com" @@ -24,8 +26,6 @@ PROFILE_HREF_PATTERN = r"^/[A-Za-z0-9_]{1,15}$" # User agent (Chrome 131 - January 2025) -USER_AGENT = ( - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " - "AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/131.0.0.0 Safari/537.36" -) +USER_AGENT_ENV_VAR = os.getenv('TWITTER_USER_AGENT', "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36") + +USER_AGENT = USER_AGENT_ENV_VAR \ No newline at end of file