Skip to content

Commit cd4503b

Browse files
feat(api): api update
1 parent af90e28 commit cd4503b

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 32
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-48449a9e476c712dc65557934c8b97ac9708b06b7f96fa5c22d135037eeb9ce5.yml
3-
openapi_spec_hash: 6a0575b3dc2ea3e5d47c4961f0251213
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/context-dev/context.dev-1ad134d4ef2ddefee790dc464dd2da3e4c0614652620b25fbb1379d8f5676526.yml
3+
openapi_spec_hash: 24809b018c6869838112f064e5558509
44
config_hash: 70e7e80b5e87f94981bee396c6cd41e8

pkg/cmd/web.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{
601601

602602
var webWebScrapeHTML = requestflag.WithInnerFlags(cli.Command{
603603
Name: "web-scrape-html",
604-
Usage: "Scrapes the given URL and returns the raw HTML content of the page.",
604+
Usage: "Scrapes the given URL and returns the raw HTML content of the page. The base\nrequest costs 1 credit; requests with browser actions cost 2 credits.",
605605
Suggest: true,
606606
Flags: []cli.Flag{
607607
&requestflag.Flag[string]{
@@ -610,6 +610,11 @@ var webWebScrapeHTML = requestflag.WithInnerFlags(cli.Command{
610610
Required: true,
611611
QueryPath: "url",
612612
},
613+
&requestflag.Flag[any]{
614+
Name: "action",
615+
Usage: "Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions.",
616+
QueryPath: "actions",
617+
},
613618
&requestflag.Flag[string]{
614619
Name: "country",
615620
Usage: "Two-letter ISO 3166-1 alpha-2 country code identifying a supported Context.dev residential proxy exit location. Must be one of Context.dev's supported countries. When provided, Context.dev fetches the target page from that country.",
@@ -711,7 +716,7 @@ var webWebScrapeHTML = requestflag.WithInnerFlags(cli.Command{
711716

712717
var webWebScrapeImages = requestflag.WithInnerFlags(cli.Command{
713718
Name: "web-scrape-images",
714-
Usage: "Extract image assets from a web page, including standard URLs, inline SVGs, data\nURIs, responsive image sources, metadata, CSS backgrounds, video posters, and\nembeds. The base request costs 1 credit. When enrichment is enabled, the entire\ncall costs 5 credits.",
719+
Usage: "Extract image assets from a web page, including standard URLs, inline SVGs, data\nURIs, responsive image sources, metadata, CSS backgrounds, video posters, and\nembeds. The base request costs 1 credit, or 2 credits with browser actions. When\nenrichment is enabled, the entire call costs 5 credits, including requests that\nalso use actions.",
715720
Suggest: true,
716721
Flags: []cli.Flag{
717722
&requestflag.Flag[string]{
@@ -720,6 +725,11 @@ var webWebScrapeImages = requestflag.WithInnerFlags(cli.Command{
720725
Required: true,
721726
QueryPath: "url",
722727
},
728+
&requestflag.Flag[any]{
729+
Name: "action",
730+
Usage: "Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions.",
731+
QueryPath: "actions",
732+
},
723733
&requestflag.Flag[any]{
724734
Name: "dedupe",
725735
Usage: "When true, visually duplicate images are removed: every image is loaded and perceptually hashed, and only the highest-resolution copy of each duplicate group is kept. Images that cannot be downloaded or hashed are kept. Default: false.",
@@ -796,6 +806,11 @@ var webWebScrapeMd = requestflag.WithInnerFlags(cli.Command{
796806
Required: true,
797807
QueryPath: "url",
798808
},
809+
&requestflag.Flag[any]{
810+
Name: "action",
811+
Usage: "Optional browser actions executed in array order after the page loads and before content is captured. Requires a paid plan. Send a JSON array in the query parameter. Maximum: 5 actions.",
812+
QueryPath: "actions",
813+
},
799814
&requestflag.Flag[string]{
800815
Name: "country",
801816
Usage: "Two-letter ISO 3166-1 alpha-2 country code identifying a supported Context.dev residential proxy exit location. Must be one of Context.dev's supported countries. When provided, Context.dev fetches the target page from that country.",

pkg/cmd/web_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ func TestWebWebScrapeHTML(t *testing.T) {
413413
"--api-key", "string",
414414
"web", "web-scrape-html",
415415
"--url", "https://example.com",
416+
"--action", "[{do: wait, timeMs: 0}]",
416417
"--country", "de",
417418
"--exclude-selector", "[x]",
418419
"--headers", "{foo: J!}",
@@ -440,6 +441,7 @@ func TestWebWebScrapeHTML(t *testing.T) {
440441
"--api-key", "string",
441442
"web", "web-scrape-html",
442443
"--url", "https://example.com",
444+
"--action", "[{do: wait, timeMs: 0}]",
443445
"--country", "de",
444446
"--exclude-selector", "[x]",
445447
"--headers", "{foo: J!}",
@@ -469,6 +471,7 @@ func TestWebWebScrapeImages(t *testing.T) {
469471
"--api-key", "string",
470472
"web", "web-scrape-images",
471473
"--url", "https://example.com",
474+
"--action", "[{do: wait, timeMs: 0}]",
472475
"--dedupe", "'true'",
473476
"--enrichment", "{classification: 'true', hostedUrl: 'true', maxTimePerMs: 1, resolution: 'true'}",
474477
"--headers", "{foo: J!}",
@@ -490,6 +493,7 @@ func TestWebWebScrapeImages(t *testing.T) {
490493
"--api-key", "string",
491494
"web", "web-scrape-images",
492495
"--url", "https://example.com",
496+
"--action", "[{do: wait, timeMs: 0}]",
493497
"--dedupe", "'true'",
494498
"--enrichment.classification", "true",
495499
"--enrichment.hosted-url", "true",
@@ -513,6 +517,7 @@ func TestWebWebScrapeMd(t *testing.T) {
513517
"--api-key", "string",
514518
"web", "web-scrape-md",
515519
"--url", "https://example.com",
520+
"--action", "[{do: wait, timeMs: 0}]",
516521
"--country", "de",
517522
"--exclude-selector", "[x]",
518523
"--headers", "{foo: J!}",
@@ -543,6 +548,7 @@ func TestWebWebScrapeMd(t *testing.T) {
543548
"--api-key", "string",
544549
"web", "web-scrape-md",
545550
"--url", "https://example.com",
551+
"--action", "[{do: wait, timeMs: 0}]",
546552
"--country", "de",
547553
"--exclude-selector", "[x]",
548554
"--headers", "{foo: J!}",

0 commit comments

Comments
 (0)