Repository navigation
Releases
v0.2.1
Behaviour change. A page that serves fewer than twelve ads while the
response's owntotalsays more remain now makes the run incomplete:
stop_reason: short_page, statuspartial, exit 6 (was status
complete, exit 0). The ads it did serve are kept.Behaviour change.
--allow-emptynow writes an empty file only for a
genuine empty result, and its sidecar saysstatus: empty(was
failed). A blocked or failed run with--allow-emptyno longer
replaces an earlier output with an empty file. It keeps its exit code
(3 or 5) and leaves that output and its sidecar untouched.
Fixed
-
--allow-emptycould destroy the output it exists to protect. With
the flag, a blocked run or a run that never obtained its content wrote
an empty JSON and CSV over the previous good result, plus a sidecar
sayingfailed. A genuinely empty, complete run (the library's own
total: 0) was labelledfailedtoo, sodiff_runs.pyrefused it. Now:- A finished run whose answer was nothing writes
[], a header-only
CSV and a sidecar withstatus: emptyand itsstop_reason. It
exits 4. - Blocked (3), never obtained (5) and partial (6) keep their exit codes.
No empty row file is written for them, and an earlier output at the
same--outis kept byte for byte, sidecar included. - When nothing earlier exists, a blocked or failed
--allow-emptyrun
writes only a sidecar, withstatus: blockedorfailed. diff_runs.pycompares anemptyrun like a complete one.
- A finished run whose answer was nothing writes
-
A listing cut short was reported as a complete region. On
2026-10-13 the library served France two ads on page 1, with
has_more: falsebesidetotal: 17,071,905, and Germany eleven on
page 2. The run stopped those regions ashas_more_falseand ended
complete. The site's page size is twelve (45 of the 47 pages in the
canary artifacts from 2026-10-09 to 2026-10-15 carried exactly twelve)
and it documents no cap, so all three engines now record such a page
undershort_pagesin the sidecar and stop that region as
short_page. A short last page that brings the count up to the stated
total is still the end of the listing, and the run is complete.
Changed
- The canary's per-region floor follows the page contract, not a
count. It required at least 12 ads per region. It now requires a full
first page of twelve and at least one new ad on page 2 in every region,
fails on any recorded short page, and re-checks every dumped payload
for a short page the run did not record. - The canary no longer requires
creative_typeon every row. Some
records carry no creative at all: on 2026-10-15, 4 of 71 had
videos: []andimage_urls: []in the payload itself, and the
parser's null is the honest value for them. The canary now checks the
column against the dumped record. It must be null exactly when the
record carries neither a video nor an image.
v0.2.0
Behaviour changes. A response whose own
totalorhas_moresays
ads exist but whosedatais empty is now a failure, not "no ads": a run
holding nothing exits 5 (was 4), and a run with other rows exits 6.
Output files follow the umask (were always 0600) and an existing file
keeps its mode. CSV cells that would run as a spreadsheet formula get a
leading'. Negative--retries,--retry-delay,--delayand
--proxy-block-retriesare refused as usage errors (exit 2).
Fixed
- An empty
databeside a non-zerototalread as "no ads". The
classifier returnedno_adsfor{"total": 5000, "has_more": true, "data": []}, so a run reported the query as matching nothing (exit 4)
while the response stated 5,000 matches. It is now a parse error in the
classifier, and each engine treats a zero-row page under such an envelope
the same way. A genuinetotal: 0is still exit 4. - Output files were 0600 whatever the umask. The atomic writer kept
the temporary file's owner-only mode. A new file now gets
0666 & ~umaskand an existing one keeps its own mode, including the
.meta.jsonsidecar. - CSV formula injection. Advertiser names, titles and creative URLs
are advertiser-written text. String cells starting with=,+,-,
@, tab, CR or LF are prefixed with'in the CSV (after list joining);
numbers and JSON are untouched. The sidecar recordscsv_cells_escaped,
and a caller's own sidecar fields win a name collision. - Negative counts and delays.
--retries -1was silently read as 0
and--retry-delay -1crashed the first retry with exit 1. All three
engines (and the refusal-only Scraper API client) now reject negative
values with an argparse error naming the flag.--retrieshas help text
saying it counts extra attempts;--retries 0still fetches once. - Wording. The README said 25 columns per ad (there are 26), and
comments described sibling routes as if they were this repo's.
Changed
- Public files no longer cite an external instruction file or its section
numbers; each comment states its rule directly. A suite check keeps it
that way.tiktok_payload.pychanged only in comments, and its recorded
digest was updated. - The canary keeps the exact payloads it received (
--dump-html) in its
artifact, so a red run can be diagnosed.
v0.1.2
Behaviour changes.
--querynow filters: it was sent without the
search type the library needs and was ignored, so every keyword run
returned the whole region. A keyword that matches nothing is exit 4 (the
library's owntotal: 0), not exit 5.diff_runs.pyrefuses two runs
that asked a different keyword, region set, ad type or window.
Fixed
- A recovered page is not a blocked one.
_fetch_with_policykept a
"refusal seen" flag that a later successful attempt never cleared, so a
retry that got the page still reported it blocked. Measured live on
2026-09-29 (pyppeteer, @nasa): one empty HTTP 200, then the profile,
thenpartial/stop_reason: blockedwithpages_failed: []. And the
HTTP -> browser switch spent a--retriesattempt, so with--retries 0
a browser started and was never asked for the page. Both fixed in all
three engines, with a check that drives the real function. --querywas ignored.search_body()sentquery_type: ""; the
library's UI sends"1", and only then does the keyword filter.
Measured 2026-09-29, DE, same window: 19,000,309 / 19,000,308 (keyword /
nonsense) before, 416 / 0 after, in all three engines. The canary now
runs a positive and a negative keyword control.- "Nothing matched" read as an API error. The library's answer is
{"code": 0, "total": 0, "has_more": false}with nodatakey, and the
classifier called that an error, so the fixed keyword search would have
made every empty result exit 5. It is exit 4. - The envelope is judged before any row. A non-zero
codeis the API
refusing even whendatais[](it read as "no ads");datathat is
not a list is a parse error; records none of which carries anid
raise instead of reading as an empty region. - A failed region was listed as having no ads.
failedholds region
numbers and was compared against a region name. diff_runs.pycompares only runs that asked the same question. The
sidecar now recordsquery,query_type,ad_typeandwindow_days.
diff_runs.pycompared almost nothing. ItsTRACKED_FIELDSwere
tiktok-profile-scraper's account columns, 26 of whichAdvertisement
does not have, so a diff of two runs reported "0 changed" whenever only
an ad's run dates, review status or audience changed. It now tracks this
repo's own columns and prints each run's share of the library's
per-region total.smoke_test.pypins every tracked name against the
dataclass and checks that a changed column is actually reported.
A copied
.env.examplesetTIKTOK_URL=nasa, a TikTok handle, which
is not a region. It is nowDE.
-
Donor prose removed from the shared core.
output_writer.py,
diff_runs.py, the engines,page_flow.py,smoke_test.py,
.github/ci_checks.pyand theDockerfilecarried text from the repos
this core was copied from — YouTube comment threads,--sort top,
reply threads, job listings, "the business",--mode comments --out software-engineer— describing those sites as if they were this one.
Rewritten from this repo's own README, code and fixtures, or deleted
where there was no measured equivalent. Explicit sibling provenance
("measured on tiktok-profile-scraper's route", "a sibling repo
(youtube-scraper) had…") is kept and now says whose it is. -
output_writer.py's docstring described--mode profileand account
statistics;page_flow.py, the engines andsmoke_test.pydescribed a
profile page, an account,video_unavailableand the embed window. All
now describe the Ad Library (or are gone). -
The engines'
_rotate_if_per_pagesaid nothing one fetch receives feeds
the next; on this route thesearch_idcursor does, and it now says so. -
smoke_test.py'srun_metatest data is anadsrun on
library.tiktok.comrather than aprofilerun on@nasa. -
.github/ci_checks.pyno longer exempts anavatar_idcolumn this repo
does not have from the credential scan. -
captcha_solver.py's docstring pointed at a "No DataDome solver" section
that does not exist in this repo (it came with the copied core). Removed. -
The Scraper API engine failed on every
--wait-text/--wait-element/
--wait-statecall, and was billed for it. It sentwaitForas a
JSON-encoded string; measured 2026-09-23 the live API answers that with
HTTP 422 "params.waitFor must be an object" and still charges $0.0005,
while the same request with an object is answered 200. It is now sent as
an object. (The target status was already read fromhttp_code; the new
regression check pins that too, driving the realfetch_htmlwith
requests.poststubbed.) -
--wait-state networkidleis refused by the Scraper API (HTTP 422
"params.waitFor.state must be one of: load, domcontentloaded", still
billed — measured 2026-09-23 on a sibling repo with the object-shaped
waitFor). The choice is removed.
v0.1.1
Correction to v0.1.0. Its
captcha_solver.pydocstring described a
2Captcha captcha-solving method for TikTok as available. That method is
deprecated, and the text no longer offers it. The challenge policy for
TikTok's slide puzzle now sayssolve: False, which matches what the
code does: no solver for it is implemented.
v0.1.0
First release. Reads TikTok's EU Ad Library — the transparency endpoint
TikTok serves without a key, an account or a proxy.
One header gates the whole thing
Measured 2026-09-22 from a bare datacentre address (Hetzner, Helsinki):
with the browser's headers HTTP 200, 12 ads
the same, minus `x-ccl-str` HTTP 421
content-type + user-agent + referer + x-ccl-str HTTP 200, 12 ads
That header is minted by the library's own JavaScript — there is no global
to read it from, and a plain fetch issued from inside the page gets 421
too. So a browser is a PREREQUISITE here rather than a fallback, which is
the reverse of this repo's two siblings, and --transport http is refused
up front with that reason.
The decoys
offsetdoes nothing. The body carries one, the library's own UI
increments it, and offsets 0, 12 and 24 returned the identical twelve
ads in the identical order. Pagination is by a base64search_id
cursor, and the END of the listing is read from that cursor rather than
fromhas_more— a cursor that stops advancing ends the run.limitdoes nothing. 12, 50 and 100 all return twelve.
A scraper that trusted either would report a complete run of duplicates.
The bug this release found in itself
An ad id is not unique. An EU ad buy commonly runs in several member
states at once and the library lists it under each. Measured, page one of
five regions within the same few seconds:
DE vs IT 11 of 12 ad ids shared
DE vs FR 9 of 12
DE vs PL 9 of 12
DE vs GB 1 of 12 <- outside the EU, bought separately
Deduping on sku across regions therefore DESTROYS data, and it did: a
two-region run collapsed France's twelve ads to two. Every row now carries
row_key ({region}:{ad_id}), the engines dedupe on it and diff_runs.py
joins on it.
Complete is not exhaustive, and here the gap is the largest in the family
The library reports 17,343,646 ads for Germany alone and serves twelve per
request — a hundred-page run holds 0.0069%. Every sidecar records
site_total_per_region, ads_per_region, sample_share_pct and
why_each_region_stopped, and the closing log prints the fraction in
words.
Also found while building
rejection_infowas order-dependent. It re-serialises a nested
object, and withoutsort_keystwo byte-identical responses produced
two different strings — so a diff would report the rejection as having
changed. Found bymake_fixtures.py --verify, which parsed a capture
and its own fixture (o == fwas True) and got different rows. Same
shape as a float32 round-trip seen on a sibling repo.- Timestamps are milliseconds. Read as seconds, 1790112836000 lands in
the year 58,700. - Selenium needed
goog:loggingPrefsat launch. It has no
request-event API, so it captures the header from Chrome's performance
log — and without that capability the log is empty and the failure
message points at the Search button, which is the wrong place to look.
Deliberately not here
impressionandspent. TikTok publishes both on every ad and both
were empty on all 216 measured across six regions. The measurement is
recorded inoutput_writer.py.- The 2Captcha Scraper API path. That service fetches a URL and hands
back what the site returned; it cannot mint a header for a request it is
not making. Refused with that reason — a feature request, not a
limitation of the product. - Any region outside the 33 the library serves.
--region USis
refused as a real country the library does not cover, not as a typo.