Skip to content

Commit 91f3131

Browse files
author
stlc-bot
committed
feat(scrape): add TikTok profile and video prebuilt parsers (#1956)
Stainless-Generated-From: f6dff866e27c29be4df51c8167b6f136b73e2c55
1 parent a0f50d2 commit 91f3131

4 files changed

Lines changed: 156 additions & 48 deletions

File tree

‎src/context/dev/types/batch_get_results_response.py‎

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class DataOkResultMetadata(BaseModel):
294294

295295
class DataOkResultParsed(BaseModel):
296296
"""
297-
Custom rules return fields after content filters; unmatched fields are null ([] for lists). The google-maps parser returns business records in data.results, google-maps-reviews returns data.reviews, and the google-play parser returns one app record as data, google-play-reviews returns data.reviews, app-store and app-store-reviews do the same for the App Store, g2-reviews returns data.reviews for a G2 product, instagram-profile and instagram-post return one record as data, instagram-feed returns data.posts, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, G2, and Instagram parsers read their data directly, independently of DOM filters and other outputs.
297+
Custom rules return fields after content filters; unmatched fields are null ([] for lists). The google-maps parser returns business records in data.results, google-maps-reviews returns data.reviews, and the google-play parser returns one app record as data, google-play-reviews returns data.reviews, app-store and app-store-reviews do the same for the App Store, g2-reviews returns data.reviews for a G2 product, instagram-profile and instagram-post return one record as data, instagram-feed returns data.posts, tiktok-profile and tiktok-video return one record as data, tiktok-feed returns data.videos, tiktok-comments returns data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return data.users, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, G2, Instagram, and TikTok parsers read their data directly, independently of DOM filters and other outputs.
298298
"""
299299

300300
data: Optional[Dict[str, object]] = None
@@ -316,6 +316,13 @@ class DataOkResultParsed(BaseModel):
316316
"instagram-profile",
317317
"instagram-post",
318318
"instagram-feed",
319+
"tiktok-profile",
320+
"tiktok-video",
321+
"tiktok-feed",
322+
"tiktok-comments",
323+
"tiktok-followers",
324+
"tiktok-following",
325+
"tiktok-user-search",
319326
"emails",
320327
"phone-numbers",
321328
"links",
@@ -512,10 +519,13 @@ class DataOkResult(BaseModel):
512519
app record as data, google-play-reviews returns data.reviews, app-store and
513520
app-store-reviews do the same for the App Store, g2-reviews returns data.reviews
514521
for a G2 product, instagram-profile and instagram-post return one record as
515-
data, instagram-feed returns data.posts, emails, phone-numbers, and links return
516-
data.emails, data.phone_numbers, and data.links from the rendered page; the
517-
store, Maps, G2, and Instagram parsers read their data directly, independently
518-
of DOM filters and other outputs.
522+
data, instagram-feed returns data.posts, tiktok-profile and tiktok-video return
523+
one record as data, tiktok-feed returns data.videos, tiktok-comments returns
524+
data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return
525+
data.users, emails, phone-numbers, and links return data.emails,
526+
data.phone_numbers, and data.links from the rendered page; the store, Maps, G2,
527+
Instagram, and TikTok parsers read their data directly, independently of DOM
528+
filters and other outputs.
519529
"""
520530

521531
product: DataOkResultProduct
@@ -817,7 +827,7 @@ class DataErrorResultMetadata(BaseModel):
817827

818828
class DataErrorResultParsed(BaseModel):
819829
"""
820-
Custom rules return fields after content filters; unmatched fields are null ([] for lists). The google-maps parser returns business records in data.results, google-maps-reviews returns data.reviews, and the google-play parser returns one app record as data, google-play-reviews returns data.reviews, app-store and app-store-reviews do the same for the App Store, g2-reviews returns data.reviews for a G2 product, instagram-profile and instagram-post return one record as data, instagram-feed returns data.posts, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, G2, and Instagram parsers read their data directly, independently of DOM filters and other outputs.
830+
Custom rules return fields after content filters; unmatched fields are null ([] for lists). The google-maps parser returns business records in data.results, google-maps-reviews returns data.reviews, and the google-play parser returns one app record as data, google-play-reviews returns data.reviews, app-store and app-store-reviews do the same for the App Store, g2-reviews returns data.reviews for a G2 product, instagram-profile and instagram-post return one record as data, instagram-feed returns data.posts, tiktok-profile and tiktok-video return one record as data, tiktok-feed returns data.videos, tiktok-comments returns data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return data.users, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, G2, Instagram, and TikTok parsers read their data directly, independently of DOM filters and other outputs.
821831
"""
822832

823833
data: Optional[Dict[str, object]] = None
@@ -839,6 +849,13 @@ class DataErrorResultParsed(BaseModel):
839849
"instagram-profile",
840850
"instagram-post",
841851
"instagram-feed",
852+
"tiktok-profile",
853+
"tiktok-video",
854+
"tiktok-feed",
855+
"tiktok-comments",
856+
"tiktok-followers",
857+
"tiktok-following",
858+
"tiktok-user-search",
842859
"emails",
843860
"phone-numbers",
844861
"links",
@@ -1036,10 +1053,13 @@ class DataErrorResult(BaseModel):
10361053
app record as data, google-play-reviews returns data.reviews, app-store and
10371054
app-store-reviews do the same for the App Store, g2-reviews returns data.reviews
10381055
for a G2 product, instagram-profile and instagram-post return one record as
1039-
data, instagram-feed returns data.posts, emails, phone-numbers, and links return
1040-
data.emails, data.phone_numbers, and data.links from the rendered page; the
1041-
store, Maps, G2, and Instagram parsers read their data directly, independently
1042-
of DOM filters and other outputs.
1056+
data, instagram-feed returns data.posts, tiktok-profile and tiktok-video return
1057+
one record as data, tiktok-feed returns data.videos, tiktok-comments returns
1058+
data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return
1059+
data.users, emails, phone-numbers, and links return data.emails,
1060+
data.phone_numbers, and data.links from the rendered page; the store, Maps, G2,
1061+
Instagram, and TikTok parsers read their data directly, independently of DOM
1062+
filters and other outputs.
10431063
"""
10441064

10451065
product: DataErrorResultProduct

‎src/context/dev/types/batch_submit_params.py‎

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,13 @@ class InputScrapeDataParseParamsPrebuiltParser(TypedDict, total=False):
251251
"instagram-profile",
252252
"instagram-post",
253253
"instagram-feed",
254+
"tiktok-profile",
255+
"tiktok-video",
256+
"tiktok-feed",
257+
"tiktok-comments",
258+
"tiktok-followers",
259+
"tiktok-following",
260+
"tiktok-user-search",
254261
"emails",
255262
"phone-numbers",
256263
"links",
@@ -292,17 +299,36 @@ class InputScrapeDataParseParamsPrebuiltParser(TypedDict, total=False):
292299
location (/explore/locations/{id}/…) in data.posts; keyword posts carry only the
293300
shortcode, owner, thumbnail, and views, plus the caption when Instagram shows
294301
it. All three Instagram parsers read public data without logging in, so private
295-
accounts return no posts and follower lists are unavailable. emails accepts any
296-
page and returns its email addresses as data.emails ([{ email }]), read from
297-
mailto links, Cloudflare-protected addresses, and visible text. phone-numbers
298-
accepts any page and returns its valid phone numbers in E.164 as
299-
data.phone_numbers ([{ phone }]), read from tel links and visible text; numbers
300-
without a country code are read for the country of the site TLD, defaulting to
301-
US. links accepts any page and returns its unique http(s) links as data.links
302-
([{ url, text }]), with absolute URLs; text falls back to aria-label or image
303-
alt and is null when a link has none. The emails parser reads the rendered page
304-
and respects content filters; the other prebuilt parsers read their data
305-
independently of DOM filters.
302+
accounts return no posts and follower lists are unavailable. tiktok-profile
303+
parses a public profile (tiktok.com/@{username}) into data: nickname, bio, bio
304+
link, follower, following, like, and video counts, verified, private, and
305+
business flags, and business category; it does not list videos. tiktok-video
306+
parses a video or photo post (/@{username}/video/{id} or
307+
/@{username}/photo/{id}) into data: caption, hashtags, mentions, author, view,
308+
like, comment, share, save, and repost counts, duration, thumbnail, a video_url
309+
that downloads without cookies, image_urls for photo posts, music, location, and
310+
ad, paid-partnership, and AI-generated flags. tiktok-feed returns videos in the
311+
tiktok-video shape as data.videos: the latest 15 from a profile URL, the top 30
312+
from a hashtag URL (/tag/{name}), or the top 12 from a search URL
313+
(/search?q={query}). tiktok-comments returns the first 20 comments of a video or
314+
photo post as data.comments: text, posted_at, like and reply counts, whether the
315+
author liked it, and the commenter. tiktok-followers and tiktok-following return
316+
up to 30 accounts of a profile as data.users, in the tiktok-profile shape.
317+
tiktok-user-search returns the top 10 accounts for a user search URL
318+
(/search/user?q={query}) as data.users: id, username, nickname, biography,
319+
avatar_url, sec_uid, follower_count, like_count, and is_verified. The TikTok
320+
parsers accept tiktok.com, www.tiktok.com, and m.tiktok.com URLs but not short
321+
links (vm.tiktok.com, vt.tiktok.com, tiktok.com/t/…). emails accepts any page
322+
and returns its email addresses as data.emails ([{ email }]), read from mailto
323+
links, Cloudflare-protected addresses, and visible text. phone-numbers accepts
324+
any page and returns its valid phone numbers in E.164 as data.phone_numbers ([{
325+
phone }]), read from tel links and visible text; numbers without a country code
326+
are read for the country of the site TLD, defaulting to US. links accepts any
327+
page and returns its unique http(s) links as data.links ([{ url, text }]), with
328+
absolute URLs; text falls back to aria-label or image alt and is null when a
329+
link has none. The emails parser reads the rendered page and respects content
330+
filters; the other prebuilt parsers read their data independently of DOM
331+
filters.
306332
"""
307333

308334
type: Required[Literal["prebuilt"]]
@@ -836,6 +862,13 @@ class InputCrawlDataParseParamsPrebuiltParser(TypedDict, total=False):
836862
"instagram-profile",
837863
"instagram-post",
838864
"instagram-feed",
865+
"tiktok-profile",
866+
"tiktok-video",
867+
"tiktok-feed",
868+
"tiktok-comments",
869+
"tiktok-followers",
870+
"tiktok-following",
871+
"tiktok-user-search",
839872
"emails",
840873
"phone-numbers",
841874
"links",
@@ -877,17 +910,36 @@ class InputCrawlDataParseParamsPrebuiltParser(TypedDict, total=False):
877910
location (/explore/locations/{id}/…) in data.posts; keyword posts carry only the
878911
shortcode, owner, thumbnail, and views, plus the caption when Instagram shows
879912
it. All three Instagram parsers read public data without logging in, so private
880-
accounts return no posts and follower lists are unavailable. emails accepts any
881-
page and returns its email addresses as data.emails ([{ email }]), read from
882-
mailto links, Cloudflare-protected addresses, and visible text. phone-numbers
883-
accepts any page and returns its valid phone numbers in E.164 as
884-
data.phone_numbers ([{ phone }]), read from tel links and visible text; numbers
885-
without a country code are read for the country of the site TLD, defaulting to
886-
US. links accepts any page and returns its unique http(s) links as data.links
887-
([{ url, text }]), with absolute URLs; text falls back to aria-label or image
888-
alt and is null when a link has none. The emails parser reads the rendered page
889-
and respects content filters; the other prebuilt parsers read their data
890-
independently of DOM filters.
913+
accounts return no posts and follower lists are unavailable. tiktok-profile
914+
parses a public profile (tiktok.com/@{username}) into data: nickname, bio, bio
915+
link, follower, following, like, and video counts, verified, private, and
916+
business flags, and business category; it does not list videos. tiktok-video
917+
parses a video or photo post (/@{username}/video/{id} or
918+
/@{username}/photo/{id}) into data: caption, hashtags, mentions, author, view,
919+
like, comment, share, save, and repost counts, duration, thumbnail, a video_url
920+
that downloads without cookies, image_urls for photo posts, music, location, and
921+
ad, paid-partnership, and AI-generated flags. tiktok-feed returns videos in the
922+
tiktok-video shape as data.videos: the latest 15 from a profile URL, the top 30
923+
from a hashtag URL (/tag/{name}), or the top 12 from a search URL
924+
(/search?q={query}). tiktok-comments returns the first 20 comments of a video or
925+
photo post as data.comments: text, posted_at, like and reply counts, whether the
926+
author liked it, and the commenter. tiktok-followers and tiktok-following return
927+
up to 30 accounts of a profile as data.users, in the tiktok-profile shape.
928+
tiktok-user-search returns the top 10 accounts for a user search URL
929+
(/search/user?q={query}) as data.users: id, username, nickname, biography,
930+
avatar_url, sec_uid, follower_count, like_count, and is_verified. The TikTok
931+
parsers accept tiktok.com, www.tiktok.com, and m.tiktok.com URLs but not short
932+
links (vm.tiktok.com, vt.tiktok.com, tiktok.com/t/…). emails accepts any page
933+
and returns its email addresses as data.emails ([{ email }]), read from mailto
934+
links, Cloudflare-protected addresses, and visible text. phone-numbers accepts
935+
any page and returns its valid phone numbers in E.164 as data.phone_numbers ([{
936+
phone }]), read from tel links and visible text; numbers without a country code
937+
are read for the country of the site TLD, defaulting to US. links accepts any
938+
page and returns its unique http(s) links as data.links ([{ url, text }]), with
939+
absolute URLs; text falls back to aria-label or image alt and is null when a
940+
link has none. The emails parser reads the rendered page and respects content
941+
filters; the other prebuilt parsers read their data independently of DOM
942+
filters.
891943
"""
892944

893945
type: Required[Literal["prebuilt"]]

‎src/context/dev/types/web_scrape_params.py‎

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
219219
"instagram-profile",
220220
"instagram-post",
221221
"instagram-feed",
222+
"tiktok-profile",
223+
"tiktok-video",
224+
"tiktok-feed",
225+
"tiktok-comments",
226+
"tiktok-followers",
227+
"tiktok-following",
228+
"tiktok-user-search",
222229
"emails",
223230
"phone-numbers",
224231
"links",
@@ -260,17 +267,36 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
260267
location (/explore/locations/{id}/…) in data.posts; keyword posts carry only the
261268
shortcode, owner, thumbnail, and views, plus the caption when Instagram shows
262269
it. All three Instagram parsers read public data without logging in, so private
263-
accounts return no posts and follower lists are unavailable. emails accepts any
264-
page and returns its email addresses as data.emails ([{ email }]), read from
265-
mailto links, Cloudflare-protected addresses, and visible text. phone-numbers
266-
accepts any page and returns its valid phone numbers in E.164 as
267-
data.phone_numbers ([{ phone }]), read from tel links and visible text; numbers
268-
without a country code are read for the country of the site TLD, defaulting to
269-
US. links accepts any page and returns its unique http(s) links as data.links
270-
([{ url, text }]), with absolute URLs; text falls back to aria-label or image
271-
alt and is null when a link has none. The emails parser reads the rendered page
272-
and respects content filters; the other prebuilt parsers read their data
273-
independently of DOM filters.
270+
accounts return no posts and follower lists are unavailable. tiktok-profile
271+
parses a public profile (tiktok.com/@{username}) into data: nickname, bio, bio
272+
link, follower, following, like, and video counts, verified, private, and
273+
business flags, and business category; it does not list videos. tiktok-video
274+
parses a video or photo post (/@{username}/video/{id} or
275+
/@{username}/photo/{id}) into data: caption, hashtags, mentions, author, view,
276+
like, comment, share, save, and repost counts, duration, thumbnail, a video_url
277+
that downloads without cookies, image_urls for photo posts, music, location, and
278+
ad, paid-partnership, and AI-generated flags. tiktok-feed returns videos in the
279+
tiktok-video shape as data.videos: the latest 15 from a profile URL, the top 30
280+
from a hashtag URL (/tag/{name}), or the top 12 from a search URL
281+
(/search?q={query}). tiktok-comments returns the first 20 comments of a video or
282+
photo post as data.comments: text, posted_at, like and reply counts, whether the
283+
author liked it, and the commenter. tiktok-followers and tiktok-following return
284+
up to 30 accounts of a profile as data.users, in the tiktok-profile shape.
285+
tiktok-user-search returns the top 10 accounts for a user search URL
286+
(/search/user?q={query}) as data.users: id, username, nickname, biography,
287+
avatar_url, sec_uid, follower_count, like_count, and is_verified. The TikTok
288+
parsers accept tiktok.com, www.tiktok.com, and m.tiktok.com URLs but not short
289+
links (vm.tiktok.com, vt.tiktok.com, tiktok.com/t/…). emails accepts any page
290+
and returns its email addresses as data.emails ([{ email }]), read from mailto
291+
links, Cloudflare-protected addresses, and visible text. phone-numbers accepts
292+
any page and returns its valid phone numbers in E.164 as data.phone_numbers ([{
293+
phone }]), read from tel links and visible text; numbers without a country code
294+
are read for the country of the site TLD, defaulting to US. links accepts any
295+
page and returns its unique http(s) links as data.links ([{ url, text }]), with
296+
absolute URLs; text falls back to aria-label or image alt and is null when a
297+
link has none. The emails parser reads the rendered page and respects content
298+
filters; the other prebuilt parsers read their data independently of DOM
299+
filters.
274300
"""
275301

276302
type: Required[Literal["prebuilt"]]

0 commit comments

Comments
 (0)