You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5d45957
Browse filesBrowse the repository at this point in the historyBrowse files
stlc-bot
committed
feat(web): add raw bytes scraping endpoint (#1081)
Copy file name to clipboardExpand all lines: pkg/cmd/web.go
+83Lines changed: 83 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -647,6 +647,48 @@ var webWebCrawlMd = requestflag.WithInnerFlags(cli.Command{
647
647
},
648
648
})
649
649
650
+
varwebWebScrapeBytes= cli.Command{
651
+
Name: "web-scrape-bytes",
652
+
Usage: "Downloads a resource and returns its bytes as base64. Supports images, PDFs,\nHTML pages, and any other content type without image conversion, text\nextraction, or character-encoding changes. HTTP compression is decoded before\nbase64 encoding. HTML is the original HTTP response; JavaScript is not rendered.\nFollows public redirects and retries failed downloads through ISP and\nresidential proxies, with a direct fallback. When country is specified, only a\nresidential proxy in that country is used. Supply headers such as Referer for\nimages that require a referring page. Downloads are not cached. Maximum decoded\nresource size: 20 MiB (20971520 bytes), before base64 encoding. Successful\nrequests cost 1 credit; errors are not billed.",
653
+
Suggest: true,
654
+
Flags: []cli.Flag{
655
+
&requestflag.Flag[string]{
656
+
Name: "url",
657
+
Usage: "Full HTTP(S) URL of the resource to download, such as an image, PDF, or page.",
658
+
Required: true,
659
+
QueryPath: "url",
660
+
},
661
+
&requestflag.Flag[string]{
662
+
Name: "country",
663
+
Usage: "Fetch the target page through a residential proxy in this country (ISO 3166-1 alpha-2).",
664
+
QueryPath: "country",
665
+
},
666
+
&requestflag.Flag[map[string]any]{
667
+
Name: "headers",
668
+
Usage: "Optional outbound HTTP headers, such as Referer, Cookie, or Authorization. Send as a JSON object or deep-object query params such as headers[Referer]=https://example.com/. Host, Content-Length, and hop-by-hop transport headers are rejected. Authorization and cookies are removed when a redirect changes origin.",
669
+
QueryPath: "headers",
670
+
},
671
+
&requestflag.Flag[[]string]{
672
+
Name: "tag",
673
+
Usage: "Comma-separated tags for tracking request usage. Up to 20 tags, each 1-50 characters.",
674
+
QueryPath: "tags",
675
+
},
676
+
&requestflag.Flag[int64]{
677
+
Name: "timeout-ms",
678
+
Usage: "Optional timeout in milliseconds for the request. If the request takes longer than this value, it will be aborted with a 408 status code. Maximum allowed value is 300000ms (5 minutes).",
679
+
QueryPath: "timeoutMS",
680
+
},
681
+
&requestflag.Flag[string]{
682
+
Name: "zdr",
683
+
Usage: "Set to enabled to bypass shared caches and omit request and response content from retained usage logs. Requires zero data retention to be enabled for your organization (contact support@context.dev), otherwise the request fails with ZDR_NOT_ENABLED. Successful ZDR responses include X-Context-ZDR: true.",
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.",
0 commit comments