22
33from __future__ import annotations
44
5+ from typing_extensions import Literal
6+
57import httpx
68
79from ..types import (
10+ web_screenshot_params ,
811 web_web_crawl_md_params ,
912 web_extract_fonts_params ,
1013 web_web_scrape_md_params ,
1114 web_web_scrape_html_params ,
1215 web_web_scrape_images_params ,
16+ web_extract_styleguide_params ,
1317 web_web_scrape_sitemap_params ,
1418)
1519from .._types import Body , Omit , Query , Headers , NotGiven , omit , not_given
2327 async_to_streamed_response_wrapper ,
2428)
2529from .._base_client import make_request_options
30+ from ..types .web_screenshot_response import WebScreenshotResponse
2631from ..types .web_web_crawl_md_response import WebWebCrawlMdResponse
2732from ..types .web_extract_fonts_response import WebExtractFontsResponse
2833from ..types .web_web_scrape_md_response import WebWebScrapeMdResponse
2934from ..types .web_web_scrape_html_response import WebWebScrapeHTMLResponse
3035from ..types .web_web_scrape_images_response import WebWebScrapeImagesResponse
36+ from ..types .web_extract_styleguide_response import WebExtractStyleguideResponse
3137from ..types .web_web_scrape_sitemap_response import WebWebScrapeSitemapResponse
3238
3339__all__ = ["WebResource" , "AsyncWebResource" ]
@@ -110,6 +116,134 @@ def extract_fonts(
110116 cast_to = WebExtractFontsResponse ,
111117 )
112118
119+ def extract_styleguide (
120+ self ,
121+ * ,
122+ direct_url : str | Omit = omit ,
123+ domain : str | Omit = omit ,
124+ timeout_ms : int | Omit = omit ,
125+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
126+ # The extra values given here take precedence over values defined on the client or passed to this method.
127+ extra_headers : Headers | None = None ,
128+ extra_query : Query | None = None ,
129+ extra_body : Body | None = None ,
130+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
131+ ) -> WebExtractStyleguideResponse :
132+ """
133+ Extract a comprehensive design system from a website including colors,
134+ typography, spacing, shadows, and UI components.
135+
136+ Args:
137+ direct_url: A specific URL to fetch the styleguide from directly, bypassing domain
138+ resolution (e.g., 'https://example.com/design-system'). When provided, the
139+ styleguide is extracted from this exact URL. You must provide either 'domain' or
140+ 'directUrl', but not both.
141+
142+ domain: Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The
143+ domain will be automatically normalized and validated. You must provide either
144+ 'domain' or 'directUrl', but not both.
145+
146+ timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer
147+ than this value, it will be aborted with a 408 status code. Maximum allowed
148+ value is 300000ms (5 minutes).
149+
150+ extra_headers: Send extra headers
151+
152+ extra_query: Add additional query parameters to the request
153+
154+ extra_body: Add additional JSON properties to the request
155+
156+ timeout: Override the client-level default timeout for this request, in seconds
157+ """
158+ return self ._get (
159+ "/web/styleguide" ,
160+ options = make_request_options (
161+ extra_headers = extra_headers ,
162+ extra_query = extra_query ,
163+ extra_body = extra_body ,
164+ timeout = timeout ,
165+ query = maybe_transform (
166+ {
167+ "direct_url" : direct_url ,
168+ "domain" : domain ,
169+ "timeout_ms" : timeout_ms ,
170+ },
171+ web_extract_styleguide_params .WebExtractStyleguideParams ,
172+ ),
173+ ),
174+ cast_to = WebExtractStyleguideResponse ,
175+ )
176+
177+ def screenshot (
178+ self ,
179+ * ,
180+ direct_url : str | Omit = omit ,
181+ domain : str | Omit = omit ,
182+ full_screenshot : Literal ["true" , "false" ] | Omit = omit ,
183+ page : Literal ["login" , "signup" , "blog" , "careers" , "pricing" , "terms" , "privacy" , "contact" ] | Omit = omit ,
184+ prioritize : Literal ["speed" , "quality" ] | Omit = omit ,
185+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
186+ # The extra values given here take precedence over values defined on the client or passed to this method.
187+ extra_headers : Headers | None = None ,
188+ extra_query : Query | None = None ,
189+ extra_body : Body | None = None ,
190+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
191+ ) -> WebScreenshotResponse :
192+ """
193+ Capture a screenshot of a website.
194+
195+ Args:
196+ direct_url: A specific URL to screenshot directly, bypassing domain resolution (e.g.,
197+ 'https://example.com/pricing'). When provided, the screenshot is taken of this
198+ exact URL. You must provide either 'domain' or 'directUrl', but not both.
199+
200+ domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The
201+ domain will be automatically normalized and validated. You must provide either
202+ 'domain' or 'directUrl', but not both.
203+
204+ full_screenshot: Optional parameter to determine screenshot type. If 'true', takes a full page
205+ screenshot capturing all content. If 'false' or not provided, takes a viewport
206+ screenshot (standard browser view).
207+
208+ page: Optional parameter to specify which page type to screenshot. If provided, the
209+ system will scrape the domain's links and use heuristics to find the most
210+ appropriate URL for the specified page type (30 supported languages). If not
211+ provided, screenshots the main domain landing page. Only applicable when using
212+ 'domain', not 'directUrl'.
213+
214+ prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for
215+ faster capture with basic quality. If 'quality', optimizes for higher quality
216+ with longer wait times. Defaults to 'quality' if not provided.
217+
218+ extra_headers: Send extra headers
219+
220+ extra_query: Add additional query parameters to the request
221+
222+ extra_body: Add additional JSON properties to the request
223+
224+ timeout: Override the client-level default timeout for this request, in seconds
225+ """
226+ return self ._get (
227+ "/web/screenshot" ,
228+ options = make_request_options (
229+ extra_headers = extra_headers ,
230+ extra_query = extra_query ,
231+ extra_body = extra_body ,
232+ timeout = timeout ,
233+ query = maybe_transform (
234+ {
235+ "direct_url" : direct_url ,
236+ "domain" : domain ,
237+ "full_screenshot" : full_screenshot ,
238+ "page" : page ,
239+ "prioritize" : prioritize ,
240+ },
241+ web_screenshot_params .WebScreenshotParams ,
242+ ),
243+ ),
244+ cast_to = WebScreenshotResponse ,
245+ )
246+
113247 def web_crawl_md (
114248 self ,
115249 * ,
@@ -464,6 +598,134 @@ async def extract_fonts(
464598 cast_to = WebExtractFontsResponse ,
465599 )
466600
601+ async def extract_styleguide (
602+ self ,
603+ * ,
604+ direct_url : str | Omit = omit ,
605+ domain : str | Omit = omit ,
606+ timeout_ms : int | Omit = omit ,
607+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
608+ # The extra values given here take precedence over values defined on the client or passed to this method.
609+ extra_headers : Headers | None = None ,
610+ extra_query : Query | None = None ,
611+ extra_body : Body | None = None ,
612+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
613+ ) -> WebExtractStyleguideResponse :
614+ """
615+ Extract a comprehensive design system from a website including colors,
616+ typography, spacing, shadows, and UI components.
617+
618+ Args:
619+ direct_url: A specific URL to fetch the styleguide from directly, bypassing domain
620+ resolution (e.g., 'https://example.com/design-system'). When provided, the
621+ styleguide is extracted from this exact URL. You must provide either 'domain' or
622+ 'directUrl', but not both.
623+
624+ domain: Domain name to extract styleguide from (e.g., 'example.com', 'google.com'). The
625+ domain will be automatically normalized and validated. You must provide either
626+ 'domain' or 'directUrl', but not both.
627+
628+ timeout_ms: Optional timeout in milliseconds for the request. If the request takes longer
629+ than this value, it will be aborted with a 408 status code. Maximum allowed
630+ value is 300000ms (5 minutes).
631+
632+ extra_headers: Send extra headers
633+
634+ extra_query: Add additional query parameters to the request
635+
636+ extra_body: Add additional JSON properties to the request
637+
638+ timeout: Override the client-level default timeout for this request, in seconds
639+ """
640+ return await self ._get (
641+ "/web/styleguide" ,
642+ options = make_request_options (
643+ extra_headers = extra_headers ,
644+ extra_query = extra_query ,
645+ extra_body = extra_body ,
646+ timeout = timeout ,
647+ query = await async_maybe_transform (
648+ {
649+ "direct_url" : direct_url ,
650+ "domain" : domain ,
651+ "timeout_ms" : timeout_ms ,
652+ },
653+ web_extract_styleguide_params .WebExtractStyleguideParams ,
654+ ),
655+ ),
656+ cast_to = WebExtractStyleguideResponse ,
657+ )
658+
659+ async def screenshot (
660+ self ,
661+ * ,
662+ direct_url : str | Omit = omit ,
663+ domain : str | Omit = omit ,
664+ full_screenshot : Literal ["true" , "false" ] | Omit = omit ,
665+ page : Literal ["login" , "signup" , "blog" , "careers" , "pricing" , "terms" , "privacy" , "contact" ] | Omit = omit ,
666+ prioritize : Literal ["speed" , "quality" ] | Omit = omit ,
667+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
668+ # The extra values given here take precedence over values defined on the client or passed to this method.
669+ extra_headers : Headers | None = None ,
670+ extra_query : Query | None = None ,
671+ extra_body : Body | None = None ,
672+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
673+ ) -> WebScreenshotResponse :
674+ """
675+ Capture a screenshot of a website.
676+
677+ Args:
678+ direct_url: A specific URL to screenshot directly, bypassing domain resolution (e.g.,
679+ 'https://example.com/pricing'). When provided, the screenshot is taken of this
680+ exact URL. You must provide either 'domain' or 'directUrl', but not both.
681+
682+ domain: Domain name to take screenshot of (e.g., 'example.com', 'google.com'). The
683+ domain will be automatically normalized and validated. You must provide either
684+ 'domain' or 'directUrl', but not both.
685+
686+ full_screenshot: Optional parameter to determine screenshot type. If 'true', takes a full page
687+ screenshot capturing all content. If 'false' or not provided, takes a viewport
688+ screenshot (standard browser view).
689+
690+ page: Optional parameter to specify which page type to screenshot. If provided, the
691+ system will scrape the domain's links and use heuristics to find the most
692+ appropriate URL for the specified page type (30 supported languages). If not
693+ provided, screenshots the main domain landing page. Only applicable when using
694+ 'domain', not 'directUrl'.
695+
696+ prioritize: Optional parameter to prioritize screenshot capture. If 'speed', optimizes for
697+ faster capture with basic quality. If 'quality', optimizes for higher quality
698+ with longer wait times. Defaults to 'quality' if not provided.
699+
700+ extra_headers: Send extra headers
701+
702+ extra_query: Add additional query parameters to the request
703+
704+ extra_body: Add additional JSON properties to the request
705+
706+ timeout: Override the client-level default timeout for this request, in seconds
707+ """
708+ return await self ._get (
709+ "/web/screenshot" ,
710+ options = make_request_options (
711+ extra_headers = extra_headers ,
712+ extra_query = extra_query ,
713+ extra_body = extra_body ,
714+ timeout = timeout ,
715+ query = await async_maybe_transform (
716+ {
717+ "direct_url" : direct_url ,
718+ "domain" : domain ,
719+ "full_screenshot" : full_screenshot ,
720+ "page" : page ,
721+ "prioritize" : prioritize ,
722+ },
723+ web_screenshot_params .WebScreenshotParams ,
724+ ),
725+ ),
726+ cast_to = WebScreenshotResponse ,
727+ )
728+
467729 async def web_crawl_md (
468730 self ,
469731 * ,
@@ -748,6 +1010,12 @@ def __init__(self, web: WebResource) -> None:
7481010 self .extract_fonts = to_raw_response_wrapper (
7491011 web .extract_fonts ,
7501012 )
1013+ self .extract_styleguide = to_raw_response_wrapper (
1014+ web .extract_styleguide ,
1015+ )
1016+ self .screenshot = to_raw_response_wrapper (
1017+ web .screenshot ,
1018+ )
7511019 self .web_crawl_md = to_raw_response_wrapper (
7521020 web .web_crawl_md ,
7531021 )
@@ -772,6 +1040,12 @@ def __init__(self, web: AsyncWebResource) -> None:
7721040 self .extract_fonts = async_to_raw_response_wrapper (
7731041 web .extract_fonts ,
7741042 )
1043+ self .extract_styleguide = async_to_raw_response_wrapper (
1044+ web .extract_styleguide ,
1045+ )
1046+ self .screenshot = async_to_raw_response_wrapper (
1047+ web .screenshot ,
1048+ )
7751049 self .web_crawl_md = async_to_raw_response_wrapper (
7761050 web .web_crawl_md ,
7771051 )
@@ -796,6 +1070,12 @@ def __init__(self, web: WebResource) -> None:
7961070 self .extract_fonts = to_streamed_response_wrapper (
7971071 web .extract_fonts ,
7981072 )
1073+ self .extract_styleguide = to_streamed_response_wrapper (
1074+ web .extract_styleguide ,
1075+ )
1076+ self .screenshot = to_streamed_response_wrapper (
1077+ web .screenshot ,
1078+ )
7991079 self .web_crawl_md = to_streamed_response_wrapper (
8001080 web .web_crawl_md ,
8011081 )
@@ -820,6 +1100,12 @@ def __init__(self, web: AsyncWebResource) -> None:
8201100 self .extract_fonts = async_to_streamed_response_wrapper (
8211101 web .extract_fonts ,
8221102 )
1103+ self .extract_styleguide = async_to_streamed_response_wrapper (
1104+ web .extract_styleguide ,
1105+ )
1106+ self .screenshot = async_to_streamed_response_wrapper (
1107+ web .screenshot ,
1108+ )
8231109 self .web_crawl_md = async_to_streamed_response_wrapper (
8241110 web .web_crawl_md ,
8251111 )
0 commit comments