If your Selenium Python script is being redirected from the USA clothing website to the European version, it’s likely due to geo-blocking or IP-based localization. Here’s how to fix it:
Why This Happens
Many global brands (e.g., Nike, Zara, H&M) automatically redirect users based on:
IP address location (if your server/VPN is in Europe).
Browser language settings (e.g., Accept-Language header).
Cookies/previous site visits (if you’ve browsed the EU site before).
Solutions to Force the USA Version
1. Use a US Proxy or VPN in Selenium
python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--proxy-server=http://us-proxy-ip:port') # Use a US proxy
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.example-clothing.com") # Should load the US site
Free Proxy Risks: Public proxies may be slow/banned. Consider paid services like Luminati, Smartproxy, or NordVPN.
Cloudflare Bypass: Some sites block proxies, so test first.
2. Modify HTTP Headers (User-Agent & Accept-Language)
python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--lang=en-US') # Set browser language to US English
chrome_options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36')
driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.example-clothing.com")
3. Add a URL Parameter (If Supported)
Some sites allow manual region selection via URL:
python
usa_url = "https://www.example-clothing.com/en-us" # Try /us or ?country=US
driver.get(usa_url)
4. Clear Cookies & Local Storage
Previous EU site visits may trigger redirects:
python
driver.get("https://www.example-clothing.com")
driver.delete_all_cookies() # Clear cookies
driver.refresh() # Reload fresh
5. Use a US-Based Cloud Browser (Advanced)
Services like BrowserStack, LambdaTest, or AWS US instances provide US IPs for Selenium.