r/learnpython • u/Forteza1990 • 4d ago
Understanding SHEIN's Bot Protection and an Open-Source Scraper
SHEIN has two different types of redirects you should understand before scraping its product pages. We noticed this while testing our Python scraper: treating them as the same problem leads to unnecessary CAPTCHA-solving attempts.
Understanding SHEIN's bot protection
SHEIN uses two main risk redirects:
- /risk/challenge:: an interactive CAPTCHA challenge. It starts with an "I am human" checkbox and can escalate into either a 3×3 image grid or a puzzle requiring users to click icons in a specific order.
- /risk/action/limit: a rate-limit response. This isn't a CAPTCHA, so there's nothing to solve.
The scraper handles these situations differently. For /risk/challenge, it clicks the initial checkbox (free) and, if necessary, sends the puzzle to 2Captcha. It supports both GridTask and CoordinatesTask challenges.
The --risk-challenge-rounds option controls challenge rounds, while --max-solves limits paid CAPTCHA solutions per run (default: 8). If SHEIN returns /risk/action/limit, the scraper exits with code 3 instead of wasting money on a solver. With --rate-limit-cooldown 300 it waits five minutes and retries once.
How well it works: on 2026-09-30 we tested five fresh US browser profiles. Three passed the challenge, each on its third round, because SHEIN usually rejects the first correct answer or two. The other two were rejected on every answer, including correct ones: SHEIN had flagged the profile itself, and only a different profile helped.
Where SHEIN product data comes from
Search and category pages expose product data through window.gbRawData, while individual product pages use Schema.org JSON-LD. The scraper uses different parsing methods depending on the page.
You get one row per product: title, brand, current and original price, discount, rating, review count and stock flags. It supports product searches, category listings and individual product URLs. It collects review counts and ratings, but doesn't extract individual customer review texts.
Installing and running the scraper
The implementation uses Python 3.9+ and Playwright with Chromium. Clone the SHEIN scraper repository on GitHub (https://github.com/2scraper/shein-scraper) and install the dependencies:
git clone https://github.com/2scraper/shein-scraper.git
cd shein-scraper
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-playwright.txt
playwright install chromium
cp .env.example .envFor regular runs, set SHEIN_CDP_ENDPOINT and TWOCAPTCHA_KEY in your .env file.
To search for products:
python3 playwright_scraper.py \
--query "summer dress" \
--max-results 20You can also scrape an individual product page:
python3 playwright_scraper.py \
--url "https://us.shein.com/dsbayvkj-p-33704388.html"Exporting and comparing results
Results are saved as JSON by default (add --format csv --out products.csv for CSV), together with a .meta.json file containing run information, including status and CAPTCHA solves spent.
There's also a diff_runs.py script for comparing two JSON exports:
python3 diff_runs.py previous.json current.jsonIt identifies newly added, removed and repriced products, which is handy for tracking prices over time.
Limitations
A few things to consider:
- Currently targets us.shein.com only; other regional domains haven't been verified. Prices are in USD.
- Only about the first 20 products of a listing are verified. Whether scrolling loads more hasn't been confirmed.
skuis shared across colours and sizes, so you get one row per product. On a product page the price is the lowest variant price.--sortis recorded in the results but not sent to SHEIN yet.- Scraper API mode doesn't support scrolling and retrieves only one page per run.
- Selenium runs a local Chrome only: it can't use a remote browser profile or a proxy with a password.