TikTok Profile scraper — an open-source (MIT) Python tool that reads public tiktok.com profile pages and writes exact follower, following, like and video counts, the bio and its link, verification and TikTok Shop seller flags and the account creation date to JSON or CSV. Measured 2026-09-22 from a bare datacentre address with no credentials of any kind, profile pages answered HTTP 200 to plain curl and to headless and headful Chromium, so it needs no key, proxy or account. Use it to build a dataset of public accounts, or compare two runs with diff_runs.py to track follower changes.
Extract public statistics from TikTok accounts — follower, following, like and video counts, the bio and its link, verification and TikTok Shop seller flags, account creation date, and the settings a creator publishes.
Playwright, Selenium or Puppeteer, or no browser at all. Captcha solving, proxies and fingerprints are wired in and, on this route, unnecessary — see below, with the measurement.
A row from sample_output.json:
{
"source": "tiktok.com",
"scraped_at": "2026-09-22T14:51:09Z",
"url": "https://www.tiktok.com/@nasa",
"sku": "7664638705177150477",
"title": "NASA",
"username": "nasa",
"user_id": "7664638705177150477",
"sec_uid": "MS4wLjABAAAAU9BRVzC8oCaegVnia8IbqWhPb_-dbU7s00Y3wS1_Nx8g5RUaYvyXrpejgjdxTwd6",
"follower_count": 1785780,
"following_count": 23,
"likes_count": 9419647,
"video_count": 46,
"friend_count": 17,
"digg_count": 0,
"likes_per_video": 204774.93,
"stats_source": "statsV2",
"verified": true,
"private_account": false,
"is_organization": true,
"is_seller": false,
"commerce_user": false,
"secret": false,
"bio": "Making the seemingly impossible, possible.✨",
"bio_link": null,
"avatar_url": "https://p16-common-sign.tiktokcdn-eu.com/tos-maliva-avt-0068/e5143212a59c09a008bf50f487d54d1f~tplv-tiktokx-cropcenter:1080:1080.jpeg?dr=10399&refresh_token=7552459a&x-expires=1790258400&x-signature=xba%2B5rCq%2FdMVnKZ3eJZTFQaZZJY%3D&t=4d5b0474&ps=13740610&shp=a5d48078&shcp=81f88b70&idc=no1a",
"avatar_id": "e5143212a59c09a008bf50f487d54d1f",
"avatar_expires_at": "2026-09-24T14:00:00+00:00",
"language": "en",
"created_at": "2026-07-20T15:55:49+00:00",
"nickname_modified_at": "2026-07-20T15:58:00+00:00",
"comment_setting": 0,
"duet_setting": 0,
"stitch_setting": 0,
"download_setting": 0,
"following_visibility": 1,
"open_favorite": false,
"show_playlist_tab": true,
"status": "ok",
"status_code": 0,
"page": 1,
"position": 1
}Full sample: sample_output.json · 3 accounts (@nasa, @khaby.lame, @zachking), 41 columns, collected 2026-09-22 (default transport, no credentials).
| Runtime | Python 3.9 or newer (the offline suite runs on 3.9 and 3.12 in CI). The default transport is plain HTTPS with no browser download; Playwright (primary), Selenium or pyppeteer is the browser fallback — one engine per virtualenv |
| Coverage | Public tiktok.com profile pages (/@handle): exact follower, following, like and video counts, the bio and its link, verification and TikTok Shop seller flags, the account creation date and the settings a creator publishes. Videos and shop products are other repos. See Coverage and limitations |
| Required for the documented scenario | Nothing. No key, no proxy, no account, no .env, no browser download |
| From a server (datacentre address) | Served: a bare Hetzner address got HTTP 200 and the full account object to curl, headless and headful Chromium (2026-09-22), and completed the Quick start on 2026-12-02 |
| Through a residential proxy | Worse than no proxy: a plain HTTP client was served on 2 of 9 pool exits, the rest got TikTok's WAF "Please wait..." interstitial (HTTP 200); a browser through the same exits was served 3 of 3, which is why --transport auto falls back to one |
| Optional: 2Captcha Scraper API | scraper_api_client.py with TWOCAPTCHA_KEY: volume from many addresses, a specific exit country, no browser of your own — not access |
| Optional: 2Captcha Scraping Browser API | --cdp-endpoint (TIKTOK_CDP_ENDPOINT), Playwright and pyppeteer only: Selenium cannot authenticate a remote CDP endpoint |
| Captcha solving | Not needed on this route: the WAF interstitial is a JavaScript challenge with no widget, and a browser clears it |
| Measured | 2026-12-02 at commit 57af702, a Hetzner datacentre address, no credentials; first on 2026-09-22. See Verification |
git clone https://github.com/2scraper/tiktok-profile-scraper
cd tiktok-profile-scraper
python3 -m venv venv
./venv/bin/pip install -r requirements.txt -r requirements-playwright.txt
./venv/bin/python playwright_scraper.py --url nasaOne clone, one virtualenv. The four tiktok-* repos share top-level
module names (product_parser, output_writer, playwright_scraper, …),
so pip install . of two of them into one environment makes the second
silently replace the first. The commands above never do that — keep it
that way, and give each repo its own venv.
That is the whole setup. No key, no .env, no browser download — the
default transport needs none of them. Install a browser only if you want
--transport browser:
./venv/bin/python -m playwright install chromiumMore accounts, in one run, in parallel:
./venv/bin/python playwright_scraper.py \
--url nasa,khaby.lame,zachking,tiktok --concurrency 4 --format both--url takes a handle, an @handle, or a full profile URL, and a
comma-separated list of any mixture of them.
It writes two files to the current directory (--out names the output,
--format csv or both adds CSV):
tiktok_profiles.json— one row per account;tiktok_profiles.meta.json—status,stop_reason, which accounts failed,handles_unavailableandstats_sources.
If the run does not end with exit 0:
- exit 3, blocked — TikTok answered with a challenge, such as its WAF
"Please wait..." interstitial.
--transport autoalready fell back to a browser; it was seen mostly through residential proxy pools, so try without a proxy. - exit 4, zero accounts — TikTok returned no account for any handle
asked. A handle that does not exist and an account that was banned get
the same answer ("user banned"); both are listed in
handles_unavailable. - exit 5 or 6, not obtained or partial — 5: the content was never obtained (a navigation timeout, a dead proxy, a remote API error); 6: some accounts were fetched and some failed, and the sidecar names them. See Exit codes.
Setup, .env and exit codes for the whole family:
How to run the 2scraper scrapers.
- Accounts only. The profile's video grid (
/api/post/item_list/) answers HTTP 200 with an empty body to every client tried; videos are in tiktok-video-scraper, shop products in tiktok-shop-scraper. See Where this repo stops. - Counts are exact but move: rows carry
statsV2, not the roundedstats, and two fetches an hour apart differ. See The trap that shapes every number in the output. - A nonexistent handle and a banned account cannot be told apart: TikTok gives both the same answer.
- The avatar URL is signed and expires after about two days;
avatar_idis the stable value. --localetranslates nothing a creator wrote.
See Three traps that look like bugs.
- TikTok Profile scraper on 2scraper.com — what it collects, requirements and related scrapers on one page.
- How to run the 2scraper scrapers: setup, proxies, exit codes and access modes — installation,
.env,.meta.jsonfor the whole family.
The same account through each engine and the Scraper API is under Engines, and what each one costs you.
| Date, commit | Check | Conditions | Result |
|---|---|---|---|
2026-12-02, 57af702 |
Quick start install | a fresh virtualenv, Python 3.13, requirements.txt + requirements-playwright.txt (Playwright 1.65.3), no browser download |
installs; every flag in the Quick start commands is in --help |
2026-12-02, 57af702 |
Quick start, as written above | the default transport, no key, proxy, account or .env, one Hetzner datacentre address |
1 row (@nasa), counts from statsV2, status: complete, exit 0; the same 41 columns in the same order as sample_output.json |
2026-12-02, 57af702 |
Offline suite | smoke_test.py, .github/ci_checks.py and pytest, core requirements only |
passed |
| 2026-09-22 | Access, transports and engines, live | a bare Hetzner datacentre address; a residential pool | curl, headless and headful Chromium all served; the three engines gave identical rows apart from live counters and the avatar signature; HTTP transport 1.54 s against 3.38 s for the browser; a residential pool served a plain HTTP client 2 of 9 times |
| 2026-10-14 to 2026-11-30 | Canary, weekly | the free job: a bare GitHub runner, no secrets, four handles (one that does not exist). The paid job: one profile through the Scraper API with the TWOCAPTCHA_KEY secret |
the free job green on every run, the last with 3 accounts from statsV2 and the missing handle reported unavailable. The paid job red since 2026-10-26: the Scraper API answers HTTP 401 to the stored key — a credential, not the site |
A TikTok profile page is server-rendered and served to anyone. Measured 2026-09-22 from a bare datacentre address (Hetzner, Helsinki, AS24940), with no credentials of any kind:
| request | result |
|---|---|
curl https://www.tiktok.com/@nasa (curl's own User-Agent) |
HTTP 200, 369,784 bytes, complete account object |
| the same with a Chrome User-Agent | HTTP 200, 386,985 bytes, complete account object |
| headless Chromium | HTTP 200, account rendered |
| headful Chromium | HTTP 200, account rendered |
Note which way round that is. A sibling repo in this family
(rakuten-scraper) found a site where curl claiming to be Chrome was
refused while curl claiming to be curl was served — the gate being the
client rather than the address. TikTok's profile route does neither.
So the default transport here is plain HTTPS and a browser is a fallback, not the engine. Measured on the same machine, three accounts, end to end, median of three runs:
--transport http 1.54 s
--transport browser 3.38 s identical rows
The browser costs 2.2x and buys nothing on this route. It is what
--transport auto falls back to the moment the site actually challenges,
because an HTTP client has nowhere to put a solved token and no DOM to find
a widget in.
What the paid products buy here, stated plainly because the honest answer is "not much on this route": volume from many addresses, a specific exit country, and no browser infrastructure of your own. Not access. If you are reading fewer than a few thousand accounts from one address, you need none of it.
This is the opposite of what this family's other repos would lead you to
expect, so it is stated with the numbers. Measured 2026-09-22,
GET /@nasa with a plain HTTP client:
| exit | served |
|---|---|
| this bare datacentre address (Hetzner, Helsinki) | 3 of 3 |
| a residential pool, nine different exits | 2 of 9 |
The seven that were not served answered HTTP 200 with 1,462 bytes whose
visible text is Please wait... — TikTok's WAF interstitial
(SlardarWAF, a _wafchallengeid element, a waf-aiso/*.js script). It
is a JavaScript challenge, not a captcha: there is no widget and nothing
for a solver to solve.
A browser clears it. Driving Chromium through the very exits that had just refused a plain HTTP client: 3 of 3 served, 0 still challenged.
So on this site --transport auto is load-bearing rather than insurance.
The run recognises the interstitial as its own state (waf_challenge),
counts it as blocked, and starts a browser — which is the measured
remedy. If you are running without a proxy from a clean address, you will
probably never see it.
TikTok publishes each count twice, and the two disagree. Every profile
page carries a stats object and a statsV2 object. Measured 2026-09-22
across eighteen accounts:
| account | stats.followerCount |
statsV2.followerCount |
error |
|---|---|---|---|
| @tiktok | 95,900,000 | 95,856,713 | +43,287 |
| @khaby.lame | 163,000,000 | 162,986,107 | +13,893 |
| @nasa | 1,800,000 | 1,785,290 | +14,710 |
| @charlidamelio | 160,200,000 | 160,206,612 | -6,612 |
| @zachking | 86,900,000 | 86,900,407 | -407 |
| a small account | 429,700 | 429,675 | +25 |
stats is rounded to three significant figures and rounds both up and
down, so a consumer cannot correct for it and cannot even tell which
direction to distrust. statsV2 is exact, and is what every row here
carries. The stats_source column records which object each row was read
from, and the run's sidecar counts them, so a run of rounded numbers is
visible rather than something you have to notice column by column.
Reading the obvious field gives a number that looks right and is wrong. That is the single most valuable thing this repo knows.
Nine refetches of one account within an hour on 2026-09-22 returned
1,785,290 ... 1,785,310 followers — all different, none wrong. Two runs of
this scraper an hour apart will differ on almost every row. diff_runs.py
reports those as changes because they are changes; the canary asserts a
floor and a range, never an equality.
41 columns per account. The full list is in sample_output.csv, cut from a
real run. The ones worth naming:
| column | note |
|---|---|
sku, user_id |
the permanent numeric account id — the join key |
username |
the @handle, which the account can change |
sec_uid |
TikTok's own per-account token, so a row is directly usable as an input to further work |
follower_count, following_count, likes_count, video_count |
exact, from statsV2 |
friend_count |
accounts that follow this one and are followed back |
digg_count |
likes this account has given. 0 means "none or hidden" — read open_favorite beside it |
likes_per_video |
arithmetic on two numbers the site published, null when the account has no videos |
stats_source |
statsV2 / stats / absent |
bio, bio_link |
bio_link was set on 9 of 12 large accounts measured |
avatar_url, avatar_id, avatar_expires_at |
see below |
is_seller, commerce_user |
TikTok Shop seller — the link to tiktok-shop-scraper |
verified, private_account, is_organization, secret |
|
created_at, nickname_modified_at |
ISO-8601 UTC; TikTok's 0 for "never" is null, not 1970 |
comment_setting, duet_setting, stitch_setting, download_setting, following_visibility, open_favorite, show_playlist_tab |
TikTok's own small integers, passed through unchanged rather than mapped to words this repo would have to invent |
The avatar URL changes on every run. It is a signed CDN URL and the
signature is re-minted per request. Measured: the signed form answers HTTP
200 with a 77 KB JPEG and expires 47.7 hours out; the same URL with the
query string stripped answers HTTP 403, so it cannot be normalised
away. avatar_id — the stable content hash from the same URL — is what
changes when the account actually changes its picture, and it is what
diff_runs.py tracks. avatar_expires_at tells you when the link dies.
--locale does not translate anything. Measured 2026-09-22:
?lang=ja and ?lang=ar return a localised page chrome and
byte-identical data — same nickname, same bio, same id, same counts.
Creator-authored text is creator-authored in whatever language they wrote
it. The flag is there because the family's CLI contract has it, and because
the page's own furniture does change.
A handle with no account gives TikTok's word "user banned". TikTok
answers a nonexistent handle with HTTP 200, a full 370 KB app shell, and
statusCode: 10221, statusMsg: "user banned", userInfo: null — the
same answer it gives for an account that really was banned. This repo
does not claim to tell the two apart, because TikTok does not. The run
reports it in the sidecar's handles_unavailable, exits 4 if nothing else
was found, and never reports it as a block.
TikTok's gating is per-route, not per-site. "TikTok is gated" is true and useless. Measured 2026-09-22:
| route | what happens |
|---|---|
/@handle — this repo |
served to everything tried |
/@handle/video/{id} |
served to plain curl, ~392 KB, full item |
/embed/@handle |
served to plain curl, ~294 KB, 11 most recent videos |
/api/post/item_list/ (the profile's video grid) |
HTTP 200, content-length: 0 |
shop.tiktok.com/** |
a slide-puzzle captcha |
The video-feed refusal is worth stating precisely, because it is the shape that fools a client. Asked with a correctly signed request generated by TikTok's own front end — msToken, X-Gnarly, X-Dynosaur, device_id all present — over headless Chromium, headful Chromium, a Windows user agent, after accepting the EU cookie consent, and through a residential exit in Peru, it answered HTTP 200 with a zero-length JSON body every time. Zero video links reached the DOM in any variant.
A client that checks response.ok calls that a success and reports an
account with no videos. This repo gives it its own state (empty_success),
counts it as blocked, and exits 3.
So:
tiktok-profile-scraper(this one) — accounts. No credentials.tiktok-video-scraper— videos and their descriptions, from the embed route and the video pages, which are open.tiktok-shop-scraper— shop products, behind a captcha, where a 2Captcha key is load-bearing rather than optional.
All four paths produce identical rows. Verified on 2026-09-22: two accounts fetched by each of the three engines, compared column by column — the only differences were the live counters and the re-minted avatar signature.
./venv/bin/python playwright_scraper.py --url nasa # primary
./venv/bin/python selenium_scraper.py --url nasa
./venv/bin/python puppeteer_scraper.py --url nasa
./venv/bin/python scraper_api_client.py --url nasa # 2Captcha Scraper APIInstall exactly one engine. The three declare mutually unsatisfiable
pins (pyee <12 vs >=13 for playwright/pyppeteer; urllib3 <2.0 vs >=2.6
for pyppeteer/selenium). They do run side by side in practice, but
pip check reports the conflict and pip may resolve it by downgrading
something you wanted. Use a virtualenv per engine.
Two engine limits worth knowing before you hit them:
- Selenium cannot use an authenticated remote CDP endpoint. Playwright
and Puppeteer take a full
ws://user:pass@host:port; chromedriver'sdebuggerAddresstakes a barehost:portwith nowhere to put a password. - Selenium's
--proxy-servercannot authenticate at all. Credentials are stripped and a warning is printed rather than letting you believe auser:passURL is doing something.
| code | meaning |
|---|---|
| 0 | ok |
| 1 | crash |
| 2 | bad usage |
| 3 | blocked |
| 4 | zero accounts — including "TikTok returned no account for every handle asked" |
| 5 | the content was never obtained (a navigation timeout, a dead proxy, a remote API error) |
| 6 | partial — some accounts fetched, some failed |
A run that finds nothing writes nothing. Last night's good output is
never replaced with []. --allow-empty is the opt-out.
Every run that writes output writes <out>.meta.json beside it, recording
the status,
the stop reason, which accounts failed by number, and
handles_unavailable and stats_sources. A run that FAILED writes neither
file, so the last good output and its own sidecar stay together; the
terminal output and exit code say what happened.
Credentials live in .env beside the scripts, never on a command line — a
secret in argv is readable by anything that can run ps.
cp .env.example .env
python3 env_config.py # prints what was picked up, WITHOUT printing secretsPrecedence, highest first: an explicit flag -> an exported environment
variable -> .env -> the default. A value still carrying a
{placeholder} is treated as unset, so a copied example is never sent to
an API as if it were a key.
Variables: TWOCAPTCHA_KEY, TIKTOK_CDP_ENDPOINT, TIKTOK_PROXY,
TIKTOK_URL.
.github/workflows/canary.yml runs a real scrape against live TikTok every
Monday from a bare GitHub runner with no secrets, and is expected to be
green.
That is not a convenience. The central claim of this README is "you need no key, no proxy and no account", and an ungated scheduled canary is that sentence under test every Monday. If TikTok ever puts the profile route behind a challenge, the badge goes red on the next weekly run and the claim is retested without anyone having to remember to.
A second job, scraper-api, fetches one profile through the paid 2Captcha
Scraper API and requires a real row. It runs on the same weekly (Monday)
schedule and on a manual dispatch. It needs the repository secret
TWOCAPTCHA_KEY; without it the job fails with an error naming the secret
instead of skipping green, because a job that never reached the site has
tested nothing. The profiles job above needs no secret.
This repository does not use one. A profile page is server-rendered and
carries the whole account object, including both count objects (stats
and the exact statsV2), so the default transport reads it with a plain
HTTPS request and falls back to a browser only when TikTok challenges.
No hosted API: this is a command-line tool you run yourself, and one command
writes the rows to JSON or CSV with a .meta.json file beside them that
records whether the run completed. To run it on a schedule, put the
Quick start command in cron or a CI job.
No. On 2026-09-22 a bare datacentre address with no credentials was served
to curl and to headless and headful Chromium, and on 2026-12-02 the Quick
start completed from a Hetzner server with no key, proxy or .env. A
residential proxy made it worse: a plain HTTP client was served on only 2
of 9 pool exits.
This is not legal advice. Scraping public pages is permitted in many jurisdictions, but TikTok's terms of service, copyright and data-protection law differ between countries. The tool reads only public profile pages, which TikTok serves to anyone, and does not log in. Keep the request rate low and do not collect personal data without a lawful basis.
On the profile route it did not: a datacentre address was served to every client tried. The refusals measured were elsewhere — TikTok's WAF "Please wait..." interstitial for a plain HTTP client on residential pool exits (a browser cleared it), and an empty HTTP 200 body from the video-grid API for every client. TikTok gates per route, not per site; see Where this repo stops.
Exactly as in the Quick start: the default transport needs
no browser, display, key, proxy or .env, and the weekly canary runs it
that way on a bare GitHub runner. Give the repo its own virtualenv. Branch
on the exit code and on status in the .meta.json.
41 columns per account, in the same order in JSON and CSV: sku and
user_id (the permanent numeric id), username, sec_uid,
follower_count, following_count, likes_count, video_count,
friend_count, digg_count, likes_per_video, stats_source, bio,
bio_link, the avatar's URL, id and expiry, verified, is_organization,
is_seller, created_at and the creator's published settings. See
What you get.
A weekly canary reads four handles, one of them nonexistent, from a bare GitHub runner with no secrets; it was green on every run from 2026-10-14 to 2026-11-30. Its separate Scraper API job is red since 2026-10-26 because the stored key is refused, not because of the site.
Same CLI conventions, same output contract (one row per item, JSON or CSV, a .meta.json sidecar and shared exit codes):
- TikTok Video scraper — TikTok videos with exact engagement, sound, hashtags…
- Weibo scraper — Hot feed, account timelines and post comments…
- YouTube scraper — Comment threads, replies, video metadata and search
- Facebook Ads scraper — Ads from Meta Ad Library keyword and advertiser searches
- Facebook scraper — Public Facebook Pages — contacts, followers, owner…
- Instagram scraper — Public profiles, posts and Reels, read logged out
All scrapers: github.com/2scraper · Need another site? Open a request
python3 smoke_test.py # the offline suite — no network, no browser needed
python3 -m pytest # the same checks, through pytestThe suite is one file of plain functions with fixtures cut from real captures. It passes with no engine library installed at all, and CI fails if an engine group reports an unexpected skip — "skipped, engine absent" reads identically to a real import error.
It also holds the fixture every repo in this family carries: the material the 2Captcha Scraping Browser's auto-solve extension
injects into every page it loads. Measured 2026-09-22 on a real
--cdp-endpoint fetch of a page TikTok served — 16 chrome-extension://
tags, 4 hunter.js, and cf-turnstile once. That last one is the trap:
carried as a marker, it reports a blocked run on a perfectly good page
over a paid connection. This repo does not carry it, and the check
splices the injection into every served fixture to keep that true rather
than accidental.
MIT. See LICENSE.
Captcha solving, the Scraping Browser API, proxies and fingerprints are four separately-billed 2Captcha products behind one key. This repo needs none of them for its own route, and says so above with the measurement.