Skip to content

Commit 54d8fb4

Browse files
author
stlc-bot
committed
feat(scrape): add Yelp reviews parser
Merge pull request #2307 from context-dot-dev/feat/yelp-reviews-parser Stainless-Generated-From: 0e315e503e18ef2869595fc64880edb2674536ad
1 parent 3d8428b commit 54d8fb4

4 files changed

Lines changed: 75 additions & 45 deletions

File tree

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

Lines changed: 16 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, 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; 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; 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
@@ -324,6 +324,7 @@ class DataOkResultParsed(BaseModel):
324324
"tiktok-following",
325325
"tiktok-user-search",
326326
"yelp-search",
327+
"yelp-reviews",
327328
"emails",
328329
"phone-numbers",
329330
"links",
@@ -524,10 +525,12 @@ class DataOkResult(BaseModel):
524525
one record as data, tiktok-feed returns data.videos, tiktok-comments returns
525526
data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return
526527
data.users, yelp-search returns up to 20 ranked organic businesses in
527-
data.businesses, plus total and pagination, from a Yelp search URL; emails,
528-
phone-numbers, and links return data.emails, data.phone_numbers, and data.links
529-
from the rendered page; the store, Maps, G2, Instagram, and TikTok parsers read
530-
their data directly, independently of DOM filters and other outputs.
528+
data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews
529+
returns up to 20 latest public reviews in data.reviews, with business details
530+
and next_offset, from a Yelp business URL; emails, phone-numbers, and links
531+
return data.emails, data.phone_numbers, and data.links from the rendered page;
532+
the store, Maps, G2, Instagram, and TikTok parsers read their data directly,
533+
independently of DOM filters and other outputs.
531534
"""
532535

533536
product: DataOkResultProduct
@@ -829,7 +832,7 @@ class DataErrorResultMetadata(BaseModel):
829832

830833
class DataErrorResultParsed(BaseModel):
831834
"""
832-
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; 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.
835+
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.
833836
"""
834837

835838
data: Optional[Dict[str, object]] = None
@@ -859,6 +862,7 @@ class DataErrorResultParsed(BaseModel):
859862
"tiktok-following",
860863
"tiktok-user-search",
861864
"yelp-search",
865+
"yelp-reviews",
862866
"emails",
863867
"phone-numbers",
864868
"links",
@@ -1060,10 +1064,12 @@ class DataErrorResult(BaseModel):
10601064
one record as data, tiktok-feed returns data.videos, tiktok-comments returns
10611065
data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return
10621066
data.users, yelp-search returns up to 20 ranked organic businesses in
1063-
data.businesses, plus total and pagination, from a Yelp search URL; emails,
1064-
phone-numbers, and links return data.emails, data.phone_numbers, and data.links
1065-
from the rendered page; the store, Maps, G2, Instagram, and TikTok parsers read
1066-
their data directly, independently of DOM filters and other outputs.
1067+
data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews
1068+
returns up to 20 latest public reviews in data.reviews, with business details
1069+
and next_offset, from a Yelp business URL; emails, phone-numbers, and links
1070+
return data.emails, data.phone_numbers, and data.links from the rendered page;
1071+
the store, Maps, G2, Instagram, and TikTok parsers read their data directly,
1072+
independently of DOM filters and other outputs.
10671073
"""
10681074

10691075
product: DataErrorResultProduct

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

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ class InputScrapeDataBatchUnifiedScrapeDataParseParamsPrebuiltParser(TypedDict,
895895
"tiktok-following",
896896
"tiktok-user-search",
897897
"yelp-search",
898+
"yelp-reviews",
898899
"emails",
899900
"phone-numbers",
900901
"links",
@@ -962,16 +963,22 @@ class InputScrapeDataBatchUnifiedScrapeDataParseParamsPrebuiltParser(TypedDict,
962963
links (vm.tiktok.com, vt.tiktok.com, tiktok.com/t/…). yelp-search accepts Yelp
963964
search URLs with find_desc and find_loc, reads start as the result offset, and
964965
returns up to 20 ranked organic businesses in data.businesses with total and
965-
pagination. emails accepts any page and returns its email addresses as
966-
data.emails ([{ email }]), read from mailto links, Cloudflare-protected
967-
addresses, and visible text. phone-numbers accepts any page and returns its
968-
valid phone numbers in E.164 as data.phone_numbers ([{ phone }]), read from tel
969-
links and visible text; numbers without a country code are read for the country
970-
of the site TLD, defaulting to US. links accepts any page and returns its unique
971-
http(s) links as data.links ([{ url, text }]), with absolute URLs; text falls
972-
back to aria-label or image alt and is null when a link has none. The emails
973-
parser reads the rendered page and respects content filters; the other prebuilt
974-
parsers read their data independently of DOM filters.
966+
pagination. yelp-reviews accepts a Yelp business URL (yelp.com/biz/{alias}),
967+
uses optional start for the offset, and always sorts newest first; unsupported
968+
sort and review filters are rejected, while tracking params are ignored. It
969+
returns up to 20 latest public reviews in data.reviews with business details and
970+
pagination.next_offset. Each review has rating, full text, updated_at, and
971+
author; owner replies and photos are not included. emails accepts any page and
972+
returns its email addresses as data.emails ([{ email }]), read from mailto
973+
links, Cloudflare-protected addresses, and visible text. phone-numbers accepts
974+
any page and returns its valid phone numbers in E.164 as data.phone_numbers ([{
975+
phone }]), read from tel links and visible text; numbers without a country code
976+
are read for the country of the site TLD, defaulting to US. links accepts any
977+
page and returns its unique http(s) links as data.links ([{ url, text }]), with
978+
absolute URLs; text falls back to aria-label or image alt and is null when a
979+
link has none. The emails parser reads the rendered page and respects content
980+
filters; the other prebuilt parsers read their data independently of DOM
981+
filters.
975982
"""
976983

977984
type: Required[Literal["prebuilt"]]
@@ -2538,6 +2545,7 @@ class InputCrawlDataBatchUnifiedCrawlDataParseParamsPrebuiltParser(TypedDict, to
25382545
"tiktok-following",
25392546
"tiktok-user-search",
25402547
"yelp-search",
2548+
"yelp-reviews",
25412549
"emails",
25422550
"phone-numbers",
25432551
"links",
@@ -2605,16 +2613,22 @@ class InputCrawlDataBatchUnifiedCrawlDataParseParamsPrebuiltParser(TypedDict, to
26052613
links (vm.tiktok.com, vt.tiktok.com, tiktok.com/t/…). yelp-search accepts Yelp
26062614
search URLs with find_desc and find_loc, reads start as the result offset, and
26072615
returns up to 20 ranked organic businesses in data.businesses with total and
2608-
pagination. emails accepts any page and returns its email addresses as
2609-
data.emails ([{ email }]), read from mailto links, Cloudflare-protected
2610-
addresses, and visible text. phone-numbers accepts any page and returns its
2611-
valid phone numbers in E.164 as data.phone_numbers ([{ phone }]), read from tel
2612-
links and visible text; numbers without a country code are read for the country
2613-
of the site TLD, defaulting to US. links accepts any page and returns its unique
2614-
http(s) links as data.links ([{ url, text }]), with absolute URLs; text falls
2615-
back to aria-label or image alt and is null when a link has none. The emails
2616-
parser reads the rendered page and respects content filters; the other prebuilt
2617-
parsers read their data independently of DOM filters.
2616+
pagination. yelp-reviews accepts a Yelp business URL (yelp.com/biz/{alias}),
2617+
uses optional start for the offset, and always sorts newest first; unsupported
2618+
sort and review filters are rejected, while tracking params are ignored. It
2619+
returns up to 20 latest public reviews in data.reviews with business details and
2620+
pagination.next_offset. Each review has rating, full text, updated_at, and
2621+
author; owner replies and photos are not included. emails accepts any page and
2622+
returns its email addresses as data.emails ([{ email }]), read from mailto
2623+
links, Cloudflare-protected addresses, and visible text. phone-numbers accepts
2624+
any page and returns its valid phone numbers in E.164 as data.phone_numbers ([{
2625+
phone }]), read from tel links and visible text; numbers without a country code
2626+
are read for the country of the site TLD, defaulting to US. links accepts any
2627+
page and returns its unique http(s) links as data.links ([{ url, text }]), with
2628+
absolute URLs; text falls back to aria-label or image alt and is null when a
2629+
link has none. The emails parser reads the rendered page and respects content
2630+
filters; the other prebuilt parsers read their data independently of DOM
2631+
filters.
26182632
"""
26192633

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

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
232232
"tiktok-following",
233233
"tiktok-user-search",
234234
"yelp-search",
235+
"yelp-reviews",
235236
"emails",
236237
"phone-numbers",
237238
"links",
@@ -299,16 +300,22 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
299300
links (vm.tiktok.com, vt.tiktok.com, tiktok.com/t/…). yelp-search accepts Yelp
300301
search URLs with find_desc and find_loc, reads start as the result offset, and
301302
returns up to 20 ranked organic businesses in data.businesses with total and
302-
pagination. emails accepts any page and returns its email addresses as
303-
data.emails ([{ email }]), read from mailto links, Cloudflare-protected
304-
addresses, and visible text. phone-numbers accepts any page and returns its
305-
valid phone numbers in E.164 as data.phone_numbers ([{ phone }]), read from tel
306-
links and visible text; numbers without a country code are read for the country
307-
of the site TLD, defaulting to US. links accepts any page and returns its unique
308-
http(s) links as data.links ([{ url, text }]), with absolute URLs; text falls
309-
back to aria-label or image alt and is null when a link has none. The emails
310-
parser reads the rendered page and respects content filters; the other prebuilt
311-
parsers read their data independently of DOM filters.
303+
pagination. yelp-reviews accepts a Yelp business URL (yelp.com/biz/{alias}),
304+
uses optional start for the offset, and always sorts newest first; unsupported
305+
sort and review filters are rejected, while tracking params are ignored. It
306+
returns up to 20 latest public reviews in data.reviews with business details and
307+
pagination.next_offset. Each review has rating, full text, updated_at, and
308+
author; owner replies and photos are not included. emails accepts any page and
309+
returns its email addresses as data.emails ([{ email }]), read from mailto
310+
links, Cloudflare-protected addresses, and visible text. phone-numbers accepts
311+
any page and returns its valid phone numbers in E.164 as data.phone_numbers ([{
312+
phone }]), read from tel links and visible text; numbers without a country code
313+
are read for the country of the site TLD, defaulting to US. links accepts any
314+
page and returns its unique http(s) links as data.links ([{ url, text }]), with
315+
absolute URLs; text falls back to aria-label or image alt and is null when a
316+
link has none. The emails parser reads the rendered page and respects content
317+
filters; the other prebuilt parsers read their data independently of DOM
318+
filters.
312319
"""
313320

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

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

Lines changed: 8 additions & 5 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; 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; 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
@@ -297,6 +297,7 @@ class Parsed(BaseModel):
297297
"tiktok-following",
298298
"tiktok-user-search",
299299
"yelp-search",
300+
"yelp-reviews",
300301
"emails",
301302
"phone-numbers",
302303
"links",
@@ -493,10 +494,12 @@ class WebScrapeResponse(BaseModel):
493494
one record as data, tiktok-feed returns data.videos, tiktok-comments returns
494495
data.comments, tiktok-followers, tiktok-following, and tiktok-user-search return
495496
data.users, yelp-search returns up to 20 ranked organic businesses in
496-
data.businesses, plus total and pagination, from a Yelp search URL; emails,
497-
phone-numbers, and links return data.emails, data.phone_numbers, and data.links
498-
from the rendered page; the store, Maps, G2, Instagram, and TikTok parsers read
499-
their data directly, independently of DOM filters and other outputs.
497+
data.businesses, plus total and pagination, from a Yelp search URL; yelp-reviews
498+
returns up to 20 latest public reviews in data.reviews, with business details
499+
and next_offset, from a Yelp business URL; emails, phone-numbers, and links
500+
return data.emails, data.phone_numbers, and data.links from the rendered page;
501+
the store, Maps, G2, Instagram, and TikTok parsers read their data directly,
502+
independently of DOM filters and other outputs.
500503
"""
501504

502505
product: Product

0 commit comments

Comments
 (0)