Skip to content

Commit fb329c9

Browse files
author
stlc-bot
committed
feat(scrape): add Instagram profile, post, and feed prebuilt parsers (#1905)
Stainless-Generated-From: 05fd2d8281b6edc0a9f012b2b106e78ef2370eb6
1 parent f91c76f commit fb329c9

4 files changed

Lines changed: 99 additions & 45 deletions

File tree

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

Lines changed: 18 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, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, and G2 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, 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.
298298
"""
299299

300300
data: Optional[Dict[str, object]] = None
@@ -313,6 +313,9 @@ class DataOkResultParsed(BaseModel):
313313
"app-store",
314314
"app-store-reviews",
315315
"g2-reviews",
316+
"instagram-profile",
317+
"instagram-post",
318+
"instagram-feed",
316319
"emails",
317320
"phone-numbers",
318321
"links",
@@ -508,10 +511,11 @@ class DataOkResult(BaseModel):
508511
google-maps-reviews returns data.reviews, and the google-play parser returns one
509512
app record as data, google-play-reviews returns data.reviews, app-store and
510513
app-store-reviews do the same for the App Store, g2-reviews returns data.reviews
511-
for a G2 product, emails, phone-numbers, and links return data.emails,
512-
data.phone_numbers, and data.links from the rendered page; the store, Maps, and
513-
G2 parsers read their data directly, independently of DOM filters and other
514-
outputs.
514+
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.
515519
"""
516520

517521
product: DataOkResultProduct
@@ -813,7 +817,7 @@ class DataErrorResultMetadata(BaseModel):
813817

814818
class DataErrorResultParsed(BaseModel):
815819
"""
816-
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, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, and G2 parsers read their data directly, independently of DOM filters and other outputs.
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.
817821
"""
818822

819823
data: Optional[Dict[str, object]] = None
@@ -832,6 +836,9 @@ class DataErrorResultParsed(BaseModel):
832836
"app-store",
833837
"app-store-reviews",
834838
"g2-reviews",
839+
"instagram-profile",
840+
"instagram-post",
841+
"instagram-feed",
835842
"emails",
836843
"phone-numbers",
837844
"links",
@@ -1028,10 +1035,11 @@ class DataErrorResult(BaseModel):
10281035
google-maps-reviews returns data.reviews, and the google-play parser returns one
10291036
app record as data, google-play-reviews returns data.reviews, app-store and
10301037
app-store-reviews do the same for the App Store, g2-reviews returns data.reviews
1031-
for a G2 product, emails, phone-numbers, and links return data.emails,
1032-
data.phone_numbers, and data.links from the rendered page; the store, Maps, and
1033-
G2 parsers read their data directly, independently of DOM filters and other
1034-
outputs.
1038+
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.
10351043
"""
10361044

10371045
product: DataErrorResultProduct

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

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ class InputScrapeDataParseParamsPrebuiltParser(TypedDict, total=False):
248248
"app-store",
249249
"app-store-reviews",
250250
"g2-reviews",
251+
"instagram-profile",
252+
"instagram-post",
253+
"instagram-feed",
251254
"emails",
252255
"phone-numbers",
253256
"links",
@@ -279,16 +282,27 @@ class InputScrapeDataParseParamsPrebuiltParser(TypedDict, total=False):
279282
plus data.product. It accepts G2 product URLs (g2.com/products/…), follows
280283
renamed products, and keeps star-rating filters from the URL
281284
(filters[nps_score][]=1 to 5); other filters, sort orders, and pages are
282-
ignored. emails accepts any page and returns its email addresses as data.emails
283-
([{ email }]), read from mailto links, Cloudflare-protected addresses, and
284-
visible text. phone-numbers accepts any page and returns its valid phone numbers
285-
in E.164 as data.phone_numbers ([{ phone }]), read from tel links and visible
286-
text; numbers without a country code are read for the country of the site TLD,
287-
defaulting to US. links accepts any page and returns its unique http(s) links as
288-
data.links ([{ url, text }]), with absolute URLs; text falls back to aria-label
289-
or image alt and is null when a link has none. The emails parser reads the
290-
rendered page and respects content filters; the other prebuilt parsers read
291-
their data independently of DOM filters.
285+
ignored. instagram-profile parses a public profile (instagram.com/{username})
286+
into data: bio, links, follower and post counts, category, business address,
287+
similar_accounts, and latest_posts (the 12 newest). instagram-post parses a post
288+
or reel (/p/…, /reel/…) into data: caption, hashtags, mentions, like, comment,
289+
and view counts, media URLs, tagged users, collaborators, location, and the top
290+
~14 comments in data.comments. instagram-feed returns the top posts for a
291+
hashtag or keyword (/explore/tags/…, /popular/…) or the recent posts at a
292+
location (/explore/locations/{id}/…) in data.posts; keyword posts carry only the
293+
shortcode, owner, thumbnail, and views, plus the caption when Instagram shows
294+
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.
292306
"""
293307

294308
type: Required[Literal["prebuilt"]]
@@ -819,6 +833,9 @@ class InputCrawlDataParseParamsPrebuiltParser(TypedDict, total=False):
819833
"app-store",
820834
"app-store-reviews",
821835
"g2-reviews",
836+
"instagram-profile",
837+
"instagram-post",
838+
"instagram-feed",
822839
"emails",
823840
"phone-numbers",
824841
"links",
@@ -850,16 +867,27 @@ class InputCrawlDataParseParamsPrebuiltParser(TypedDict, total=False):
850867
plus data.product. It accepts G2 product URLs (g2.com/products/…), follows
851868
renamed products, and keeps star-rating filters from the URL
852869
(filters[nps_score][]=1 to 5); other filters, sort orders, and pages are
853-
ignored. emails accepts any page and returns its email addresses as data.emails
854-
([{ email }]), read from mailto links, Cloudflare-protected addresses, and
855-
visible text. phone-numbers accepts any page and returns its valid phone numbers
856-
in E.164 as data.phone_numbers ([{ phone }]), read from tel links and visible
857-
text; numbers without a country code are read for the country of the site TLD,
858-
defaulting to US. links accepts any page and returns its unique http(s) links as
859-
data.links ([{ url, text }]), with absolute URLs; text falls back to aria-label
860-
or image alt and is null when a link has none. The emails parser reads the
861-
rendered page and respects content filters; the other prebuilt parsers read
862-
their data independently of DOM filters.
870+
ignored. instagram-profile parses a public profile (instagram.com/{username})
871+
into data: bio, links, follower and post counts, category, business address,
872+
similar_accounts, and latest_posts (the 12 newest). instagram-post parses a post
873+
or reel (/p/…, /reel/…) into data: caption, hashtags, mentions, like, comment,
874+
and view counts, media URLs, tagged users, collaborators, location, and the top
875+
~14 comments in data.comments. instagram-feed returns the top posts for a
876+
hashtag or keyword (/explore/tags/…, /popular/…) or the recent posts at a
877+
location (/explore/locations/{id}/…) in data.posts; keyword posts carry only the
878+
shortcode, owner, thumbnail, and views, plus the caption when Instagram shows
879+
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.
863891
"""
864892

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

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

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
216216
"app-store",
217217
"app-store-reviews",
218218
"g2-reviews",
219+
"instagram-profile",
220+
"instagram-post",
221+
"instagram-feed",
219222
"emails",
220223
"phone-numbers",
221224
"links",
@@ -247,16 +250,27 @@ class ParseParamsPrebuiltParser(TypedDict, total=False):
247250
plus data.product. It accepts G2 product URLs (g2.com/products/…), follows
248251
renamed products, and keeps star-rating filters from the URL
249252
(filters[nps_score][]=1 to 5); other filters, sort orders, and pages are
250-
ignored. emails accepts any page and returns its email addresses as data.emails
251-
([{ email }]), read from mailto links, Cloudflare-protected addresses, and
252-
visible text. phone-numbers accepts any page and returns its valid phone numbers
253-
in E.164 as data.phone_numbers ([{ phone }]), read from tel links and visible
254-
text; numbers without a country code are read for the country of the site TLD,
255-
defaulting to US. links accepts any page and returns its unique http(s) links as
256-
data.links ([{ url, text }]), with absolute URLs; text falls back to aria-label
257-
or image alt and is null when a link has none. The emails parser reads the
258-
rendered page and respects content filters; the other prebuilt parsers read
259-
their data independently of DOM filters.
253+
ignored. instagram-profile parses a public profile (instagram.com/{username})
254+
into data: bio, links, follower and post counts, category, business address,
255+
similar_accounts, and latest_posts (the 12 newest). instagram-post parses a post
256+
or reel (/p/…, /reel/…) into data: caption, hashtags, mentions, like, comment,
257+
and view counts, media URLs, tagged users, collaborators, location, and the top
258+
~14 comments in data.comments. instagram-feed returns the top posts for a
259+
hashtag or keyword (/explore/tags/…, /popular/…) or the recent posts at a
260+
location (/explore/locations/{id}/…) in data.posts; keyword posts carry only the
261+
shortcode, owner, thumbnail, and views, plus the caption when Instagram shows
262+
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.
260274
"""
261275

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

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

Lines changed: 9 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, emails, phone-numbers, and links return data.emails, data.phone_numbers, and data.links from the rendered page; the store, Maps, and G2 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, 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.
271271
"""
272272

273273
data: Optional[Dict[str, object]] = None
@@ -286,6 +286,9 @@ class Parsed(BaseModel):
286286
"app-store",
287287
"app-store-reviews",
288288
"g2-reviews",
289+
"instagram-profile",
290+
"instagram-post",
291+
"instagram-feed",
289292
"emails",
290293
"phone-numbers",
291294
"links",
@@ -477,10 +480,11 @@ class WebScrapeResponse(BaseModel):
477480
google-maps-reviews returns data.reviews, and the google-play parser returns one
478481
app record as data, google-play-reviews returns data.reviews, app-store and
479482
app-store-reviews do the same for the App Store, g2-reviews returns data.reviews
480-
for a G2 product, emails, phone-numbers, and links return data.emails,
481-
data.phone_numbers, and data.links from the rendered page; the store, Maps, and
482-
G2 parsers read their data directly, independently of DOM filters and other
483-
outputs.
483+
for a G2 product, instagram-profile and instagram-post return one record as
484+
data, instagram-feed returns data.posts, emails, phone-numbers, and links return
485+
data.emails, data.phone_numbers, and data.links from the rendered page; the
486+
store, Maps, G2, and Instagram parsers read their data directly, independently
487+
of DOM filters and other outputs.
484488
"""
485489

486490
product: Product

0 commit comments

Comments
 (0)