Skip to content

Commit 8251b05

Browse files
author
stlc-bot
committed
feat(scrape): add Tripadvisor reviews parser (#2508)
Stainless-Generated-From: 5c1b6ad18f316dfd31c3375de6a803109db790d2
1 parent dd8b290 commit 8251b05

4 files changed

Lines changed: 75 additions & 36 deletions

File tree

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

Lines changed: 10 additions & 4 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, 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, yelp-search returns up to 20 ranked organic businesses in data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews returns up to 20 latest public reviews in data.reviews, with business details and next_offset, from a Yelp business URL; 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.
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, yelp-search returns up to 20 ranked organic businesses in data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews returns up to 20 latest public reviews in data.reviews, with business details and next_offset, from a Yelp business URL; tripadvisor-reviews returns 20 reviews in data.reviews, with data.location and next_offset, from a Tripadvisor hotel, restaurant, or attraction review URL; 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
@@ -329,6 +329,7 @@ class DataOkResultParsed(BaseModel):
329329
"reddit-user",
330330
"yelp-search",
331331
"yelp-reviews",
332+
"tripadvisor-reviews",
332333
"emails",
333334
"phone-numbers",
334335
"links",
@@ -531,7 +532,9 @@ class DataOkResult(BaseModel):
531532
data.users, yelp-search returns up to 20 ranked organic businesses in
532533
data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews
533534
returns up to 20 latest public reviews in data.reviews, with business details
534-
and next_offset, from a Yelp business URL; emails, phone-numbers, and links
535+
and next_offset, from a Yelp business URL; tripadvisor-reviews returns 20
536+
reviews in data.reviews, with data.location and next_offset, from a Tripadvisor
537+
hotel, restaurant, or attraction review URL; emails, phone-numbers, and links
535538
return data.emails, data.phone_numbers, and data.links from the rendered page;
536539
the store, Maps, G2, Instagram, and TikTok parsers read their data directly,
537540
independently of DOM filters and other outputs.
@@ -836,7 +839,7 @@ class DataErrorResultMetadata(BaseModel):
836839

837840
class DataErrorResultParsed(BaseModel):
838841
"""
839-
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, yelp-search returns up to 20 ranked organic businesses in data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews returns up to 20 latest public reviews in data.reviews, with business details and next_offset, from a Yelp business URL; 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.
842+
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, yelp-search returns up to 20 ranked organic businesses in data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews returns up to 20 latest public reviews in data.reviews, with business details and next_offset, from a Yelp business URL; tripadvisor-reviews returns 20 reviews in data.reviews, with data.location and next_offset, from a Tripadvisor hotel, restaurant, or attraction review URL; 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.
840843
"""
841844

842845
data: Optional[Dict[str, object]] = None
@@ -871,6 +874,7 @@ class DataErrorResultParsed(BaseModel):
871874
"reddit-user",
872875
"yelp-search",
873876
"yelp-reviews",
877+
"tripadvisor-reviews",
874878
"emails",
875879
"phone-numbers",
876880
"links",
@@ -1074,7 +1078,9 @@ class DataErrorResult(BaseModel):
10741078
data.users, yelp-search returns up to 20 ranked organic businesses in
10751079
data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews
10761080
returns up to 20 latest public reviews in data.reviews, with business details
1077-
and next_offset, from a Yelp business URL; emails, phone-numbers, and links
1081+
and next_offset, from a Yelp business URL; tripadvisor-reviews returns 20
1082+
reviews in data.reviews, with data.location and next_offset, from a Tripadvisor
1083+
hotel, restaurant, or attraction review URL; emails, phone-numbers, and links
10781084
return data.emails, data.phone_numbers, and data.links from the rendered page;
10791085
the store, Maps, G2, Instagram, and TikTok parsers read their data directly,
10801086
independently of DOM filters and other outputs.

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

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ class InputScrapeDataBatchUnifiedScrapeDataParseParamsPrebuiltParser(TypedDict,
903903
"reddit-user",
904904
"yelp-search",
905905
"yelp-reviews",
906+
"tripadvisor-reviews",
906907
"emails",
907908
"phone-numbers",
908909
"links",
@@ -1026,16 +1027,25 @@ class InputScrapeDataBatchUnifiedScrapeDataParseParamsPrebuiltParser(TypedDict,
10261027
pagination.next_offset. Each review has rating, full text, updated_at, and
10271028
author (id is the Yelp user id from the reviewer profile URL, url links to that
10281029
profile, plus name, location, and review_count); owner replies and photos are
1029-
not included. emails accepts any page and returns its email addresses as
1030-
data.emails ([{ email }]), read from mailto links, Cloudflare-protected
1031-
addresses, and visible text. phone-numbers accepts any page and returns its
1032-
valid phone numbers in E.164 as data.phone_numbers ([{ phone }]), read from tel
1033-
links and visible text; numbers without a country code are read for the country
1034-
of the site TLD, defaulting to US. links accepts any page and returns its unique
1035-
http(s) links as data.links ([{ url, text }]), with absolute URLs; text falls
1036-
back to aria-label or image alt and is null when a link has none. The emails
1037-
parser reads the rendered page and respects content filters; the other prebuilt
1038-
parsers read their data independently of DOM filters.
1030+
not included. tripadvisor-reviews accepts a Tripadvisor hotel, restaurant, or
1031+
attraction review URL (tripadvisor.com/Hotel_Review-g{geo}-d{id}-Reviews-….html,
1032+
on any Tripadvisor country domain), reads -or{N}- in the path as the offset, and
1033+
returns 20 reviews in data.reviews in the order Tripadvisor shows them, with
1034+
data.location (id, name, type, url, review_count) and pagination.next_offset.
1035+
Each review has id, url, title, full text, rating, language, published_at,
1036+
visit_month, helpful_votes, subratings, photo_urls, owner_response (text,
1037+
published_at, author_name), and author (id, username, name, url,
1038+
contribution_count); an unknown location returns no reviews. emails accepts any
1039+
page and returns its email addresses as data.emails ([{ email }]), read from
1040+
mailto links, Cloudflare-protected addresses, and visible text. phone-numbers
1041+
accepts any page and returns its valid phone numbers in E.164 as
1042+
data.phone_numbers ([{ phone }]), read from tel links and visible text; numbers
1043+
without a country code are read for the country of the site TLD, defaulting to
1044+
US. links accepts any page and returns its unique http(s) links as data.links
1045+
([{ url, text }]), with absolute URLs; text falls back to aria-label or image
1046+
alt and is null when a link has none. The emails parser reads the rendered page
1047+
and respects content filters; the other prebuilt parsers read their data
1048+
independently of DOM filters.
10391049
"""
10401050

10411051
type: Required[Literal["prebuilt"]]
@@ -2612,6 +2622,7 @@ class InputCrawlDataBatchUnifiedCrawlDataParseParamsPrebuiltParser(TypedDict, to
26122622
"reddit-user",
26132623
"yelp-search",
26142624
"yelp-reviews",
2625+
"tripadvisor-reviews",
26152626
"emails",
26162627
"phone-numbers",
26172628
"links",
@@ -2735,16 +2746,25 @@ class InputCrawlDataBatchUnifiedCrawlDataParseParamsPrebuiltParser(TypedDict, to
27352746
pagination.next_offset. Each review has rating, full text, updated_at, and
27362747
author (id is the Yelp user id from the reviewer profile URL, url links to that
27372748
profile, plus name, location, and review_count); owner replies and photos are
2738-
not included. emails accepts any page and returns its email addresses as
2739-
data.emails ([{ email }]), read from mailto links, Cloudflare-protected
2740-
addresses, and visible text. phone-numbers accepts any page and returns its
2741-
valid phone numbers in E.164 as data.phone_numbers ([{ phone }]), read from tel
2742-
links and visible text; numbers without a country code are read for the country
2743-
of the site TLD, defaulting to US. links accepts any page and returns its unique
2744-
http(s) links as data.links ([{ url, text }]), with absolute URLs; text falls
2745-
back to aria-label or image alt and is null when a link has none. The emails
2746-
parser reads the rendered page and respects content filters; the other prebuilt
2747-
parsers read their data independently of DOM filters.
2749+
not included. tripadvisor-reviews accepts a Tripadvisor hotel, restaurant, or
2750+
attraction review URL (tripadvisor.com/Hotel_Review-g{geo}-d{id}-Reviews-….html,
2751+
on any Tripadvisor country domain), reads -or{N}- in the path as the offset, and
2752+
returns 20 reviews in data.reviews in the order Tripadvisor shows them, with
2753+
data.location (id, name, type, url, review_count) and pagination.next_offset.
2754+
Each review has id, url, title, full text, rating, language, published_at,
2755+
visit_month, helpful_votes, subratings, photo_urls, owner_response (text,
2756+
published_at, author_name), and author (id, username, name, url,
2757+
contribution_count); an unknown location returns no reviews. emails accepts any
2758+
page and returns its email addresses as data.emails ([{ email }]), read from
2759+
mailto links, Cloudflare-protected addresses, and visible text. phone-numbers
2760+
accepts any page and returns its valid phone numbers in E.164 as
2761+
data.phone_numbers ([{ phone }]), read from tel links and visible text; numbers
2762+
without a country code are read for the country of the site TLD, defaulting to
2763+
US. links accepts any page and returns its unique http(s) links as data.links
2764+
([{ url, text }]), with absolute URLs; text falls back to aria-label or image
2765+
alt and is null when a link has none. The emails parser reads the rendered page
2766+
and respects content filters; the other prebuilt parsers read their data
2767+
independently of DOM filters.
27482768
"""
27492769

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

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

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
240240
"reddit-user",
241241
"yelp-search",
242242
"yelp-reviews",
243+
"tripadvisor-reviews",
243244
"emails",
244245
"phone-numbers",
245246
"links",
@@ -363,16 +364,25 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
363364
pagination.next_offset. Each review has rating, full text, updated_at, and
364365
author (id is the Yelp user id from the reviewer profile URL, url links to that
365366
profile, plus name, location, and review_count); owner replies and photos are
366-
not included. emails accepts any page and returns its email addresses as
367-
data.emails ([{ email }]), read from mailto links, Cloudflare-protected
368-
addresses, and visible text. phone-numbers accepts any page and returns its
369-
valid phone numbers in E.164 as data.phone_numbers ([{ phone }]), read from tel
370-
links and visible text; numbers without a country code are read for the country
371-
of the site TLD, defaulting to US. links accepts any page and returns its unique
372-
http(s) links as data.links ([{ url, text }]), with absolute URLs; text falls
373-
back to aria-label or image alt and is null when a link has none. The emails
374-
parser reads the rendered page and respects content filters; the other prebuilt
375-
parsers read their data independently of DOM filters.
367+
not included. tripadvisor-reviews accepts a Tripadvisor hotel, restaurant, or
368+
attraction review URL (tripadvisor.com/Hotel_Review-g{geo}-d{id}-Reviews-….html,
369+
on any Tripadvisor country domain), reads -or{N}- in the path as the offset, and
370+
returns 20 reviews in data.reviews in the order Tripadvisor shows them, with
371+
data.location (id, name, type, url, review_count) and pagination.next_offset.
372+
Each review has id, url, title, full text, rating, language, published_at,
373+
visit_month, helpful_votes, subratings, photo_urls, owner_response (text,
374+
published_at, author_name), and author (id, username, name, url,
375+
contribution_count); an unknown location returns no reviews. emails accepts any
376+
page and returns its email addresses as data.emails ([{ email }]), read from
377+
mailto links, Cloudflare-protected addresses, and visible text. phone-numbers
378+
accepts any page and returns its valid phone numbers in E.164 as
379+
data.phone_numbers ([{ phone }]), read from tel links and visible text; numbers
380+
without a country code are read for the country of the site TLD, defaulting to
381+
US. links accepts any page and returns its unique http(s) links as data.links
382+
([{ url, text }]), with absolute URLs; text falls back to aria-label or image
383+
alt and is null when a link has none. The emails parser reads the rendered page
384+
and respects content filters; the other prebuilt parsers read their data
385+
independently of DOM filters.
376386
"""
377387

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

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class Metadata(BaseModel):
267267

268268
class Parsed(BaseModel):
269269
"""
270-
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, yelp-search returns up to 20 ranked organic businesses in data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews returns up to 20 latest public reviews in data.reviews, with business details and next_offset, from a Yelp business URL; 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.
270+
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, yelp-search returns up to 20 ranked organic businesses in data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews returns up to 20 latest public reviews in data.reviews, with business details and next_offset, from a Yelp business URL; tripadvisor-reviews returns 20 reviews in data.reviews, with data.location and next_offset, from a Tripadvisor hotel, restaurant, or attraction review URL; 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.
271271
"""
272272

273273
data: Optional[Dict[str, object]] = None
@@ -302,6 +302,7 @@ class Parsed(BaseModel):
302302
"reddit-user",
303303
"yelp-search",
304304
"yelp-reviews",
305+
"tripadvisor-reviews",
305306
"emails",
306307
"phone-numbers",
307308
"links",
@@ -500,7 +501,9 @@ class WebScrapeResponse(BaseModel):
500501
data.users, yelp-search returns up to 20 ranked organic businesses in
501502
data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews
502503
returns up to 20 latest public reviews in data.reviews, with business details
503-
and next_offset, from a Yelp business URL; emails, phone-numbers, and links
504+
and next_offset, from a Yelp business URL; tripadvisor-reviews returns 20
505+
reviews in data.reviews, with data.location and next_offset, from a Tripadvisor
506+
hotel, restaurant, or attraction review URL; emails, phone-numbers, and links
504507
return data.emails, data.phone_numbers, and data.links from the rendered page;
505508
the store, Maps, G2, Instagram, and TikTok parsers read their data directly,
506509
independently of DOM filters and other outputs.

0 commit comments

Comments
 (0)