Class: ContextDev::Resources::Web
- Inherits:
-
Object
- Object
- ContextDev::Resources::Web
- Defined in:
- lib/context_dev/resources/web.rb,
sig/context_dev/resources/web.rbs
Instance Method Summary collapse
-
#extract(schema:, url:, fact_check: nil, follow_subdomains: nil, include_frames: nil, instructions: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, stop_after_ms: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractResponse
Some parameter documentations has been truncated, see Models::WebExtractParams for more details.
-
#extract_competitors(domain:, num_competitors: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractCompetitorsResponse
Some parameter documentations has been truncated, see Models::WebExtractCompetitorsParams for more details.
-
#extract_fonts(direct_url: nil, domain: nil, max_age_ms: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractFontsResponse
Some parameter documentations has been truncated, see Models::WebExtractFontsParams for more details.
-
#extract_styleguide(color_scheme: nil, direct_url: nil, domain: nil, max_age_ms: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractStyleguideResponse
Some parameter documentations has been truncated, see Models::WebExtractStyleguideParams for more details.
-
#initialize(client:) ⇒ Web
constructor
private
A new instance of Web.
-
#screenshot(color_scheme: nil, country: nil, direct_url: nil, domain: nil, full_screenshot: nil, handle_cookie_popup: nil, max_age_ms: nil, page: nil, scroll_offset: nil, timeout_ms: nil, viewport: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebScreenshotResponse
Some parameter documentations has been truncated, see Models::WebScreenshotParams for more details.
-
#search(query:, country: nil, exclude_domains: nil, freshness: nil, include_domains: nil, markdown_options: nil, num_results: nil, query_fanout: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebSearchResponse
Some parameter documentations has been truncated, see Models::WebSearchParams for more details.
-
#web_crawl_md(url:, country: nil, exclude_selectors: nil, follow_subdomains: nil, include_frames: nil, include_images: nil, include_links: nil, include_selectors: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, settle_animations: nil, shorten_base64_images: nil, stop_after_ms: nil, timeout_ms: nil, url_regex: nil, use_main_content_only: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebCrawlMdResponse
Some parameter documentations has been truncated, see Models::WebWebCrawlMdParams for more details.
-
#web_scrape_html(url:, country: nil, exclude_selectors: nil, headers: nil, include_frames: nil, include_selectors: nil, max_age_ms: nil, pdf: nil, settle_animations: nil, timeout_ms: nil, use_main_content_only: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeHTMLResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeHTMLParams for more details.
-
#web_scrape_images(url:, dedupe: nil, enrichment: nil, headers: nil, max_age_ms: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeImagesResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeImagesParams for more details.
-
#web_scrape_md(url:, country: nil, exclude_selectors: nil, headers: nil, include_frames: nil, include_images: nil, include_links: nil, include_selectors: nil, max_age_ms: nil, pdf: nil, settle_animations: nil, shorten_base64_images: nil, timeout_ms: nil, use_main_content_only: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeMdResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeMdParams for more details.
-
#web_scrape_sitemap(domain:, headers: nil, max_links: nil, timeout_ms: nil, url_regex: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeSitemapResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeSitemapParams for more details.
Constructor Details
#initialize(client:) ⇒ Web
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Web.
529 530 531 |
# File 'lib/context_dev/resources/web.rb', line 529 def initialize(client:) @client = client end |
Instance Method Details
#extract(schema:, url:, fact_check: nil, follow_subdomains: nil, include_frames: nil, instructions: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, stop_after_ms: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractResponse
Some parameter documentations has been truncated, see Models::WebExtractParams for more details.
Crawl a website, use the provided JSON Schema and instructions to prioritize relevant internal links, and extract structured data from the selected pages.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/context_dev/resources/web.rb', line 45 def extract(params) parsed, = ContextDev::WebExtractParams.dump_request(params) @client.request( method: :post, path: "web/extract", body: parsed, model: ContextDev::Models::WebExtractResponse, options: ) end |
#extract_competitors(domain:, num_competitors: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractCompetitorsResponse
Some parameter documentations has been truncated, see Models::WebExtractCompetitorsParams for more details.
Analyze a company's landing page and web search evidence to return direct competitors for the same product or market.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/context_dev/resources/web.rb', line 75 def extract_competitors(params) parsed, = ContextDev::WebExtractCompetitorsParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/competitors", query: query.transform_keys(num_competitors: "numCompetitors", timeout_ms: "timeoutMS"), model: ContextDev::Models::WebExtractCompetitorsResponse, options: ) end |
#extract_fonts(direct_url: nil, domain: nil, max_age_ms: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractFontsResponse
Some parameter documentations has been truncated, see Models::WebExtractFontsParams for more details.
Scrape font information from a website including font families, usage statistics, fallbacks, and element/word counts.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/context_dev/resources/web.rb', line 108 def extract_fonts(params = {}) parsed, = ContextDev::WebExtractFontsParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/fonts", query: query.transform_keys( direct_url: "directUrl", max_age_ms: "maxAgeMs", timeout_ms: "timeoutMS" ), model: ContextDev::Models::WebExtractFontsResponse, options: ) end |
#extract_styleguide(color_scheme: nil, direct_url: nil, domain: nil, max_age_ms: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebExtractStyleguideResponse
Some parameter documentations has been truncated, see Models::WebExtractStyleguideParams for more details.
Extract a comprehensive design system from a website including colors, typography, spacing, shadows, and UI components.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/context_dev/resources/web.rb', line 147 def extract_styleguide(params = {}) parsed, = ContextDev::WebExtractStyleguideParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/styleguide", query: query.transform_keys( color_scheme: "colorScheme", direct_url: "directUrl", max_age_ms: "maxAgeMs", timeout_ms: "timeoutMS" ), model: ContextDev::Models::WebExtractStyleguideResponse, options: ) end |
#screenshot(color_scheme: nil, country: nil, direct_url: nil, domain: nil, full_screenshot: nil, handle_cookie_popup: nil, max_age_ms: nil, page: nil, scroll_offset: nil, timeout_ms: nil, viewport: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebScreenshotResponse
Some parameter documentations has been truncated, see Models::WebScreenshotParams for more details.
Capture a screenshot of a website.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/context_dev/resources/web.rb', line 200 def screenshot(params = {}) parsed, = ContextDev::WebScreenshotParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/screenshot", query: query.transform_keys( color_scheme: "colorScheme", direct_url: "directUrl", full_screenshot: "fullScreenshot", handle_cookie_popup: "handleCookiePopup", max_age_ms: "maxAgeMs", scroll_offset: "scrollOffset", timeout_ms: "timeoutMS", wait_for_ms: "waitForMs" ), model: ContextDev::Models::WebScreenshotResponse, options: ) end |
#search(query:, country: nil, exclude_domains: nil, freshness: nil, include_domains: nil, markdown_options: nil, num_results: nil, query_fanout: nil, timeout_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebSearchResponse
Some parameter documentations has been truncated, see Models::WebSearchParams for more details.
Search the web and optionally scrape each result to Markdown in one round-trip.
251 252 253 254 255 256 257 258 259 260 |
# File 'lib/context_dev/resources/web.rb', line 251 def search(params) parsed, = ContextDev::WebSearchParams.dump_request(params) @client.request( method: :post, path: "web/search", body: parsed, model: ContextDev::Models::WebSearchResponse, options: ) end |
#web_crawl_md(url:, country: nil, exclude_selectors: nil, follow_subdomains: nil, include_frames: nil, include_images: nil, include_links: nil, include_selectors: nil, max_age_ms: nil, max_depth: nil, max_pages: nil, pdf: nil, settle_animations: nil, shorten_base64_images: nil, stop_after_ms: nil, timeout_ms: nil, url_regex: nil, use_main_content_only: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebCrawlMdResponse
Some parameter documentations has been truncated, see Models::WebWebCrawlMdParams for more details.
Performs a crawl starting from a given URL, extracts page content as Markdown, and returns results for all crawled pages.
313 314 315 316 317 318 319 320 321 322 |
# File 'lib/context_dev/resources/web.rb', line 313 def web_crawl_md(params) parsed, = ContextDev::WebWebCrawlMdParams.dump_request(params) @client.request( method: :post, path: "web/crawl", body: parsed, model: ContextDev::Models::WebWebCrawlMdResponse, options: ) end |
#web_scrape_html(url:, country: nil, exclude_selectors: nil, headers: nil, include_frames: nil, include_selectors: nil, max_age_ms: nil, pdf: nil, settle_animations: nil, timeout_ms: nil, use_main_content_only: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeHTMLResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeHTMLParams for more details.
Scrapes the given URL and returns the raw HTML content of the page.
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/context_dev/resources/web.rb', line 360 def web_scrape_html(params) parsed, = ContextDev::WebWebScrapeHTMLParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/scrape/html", query: query.transform_keys( exclude_selectors: "excludeSelectors", include_frames: "includeFrames", include_selectors: "includeSelectors", max_age_ms: "maxAgeMs", settle_animations: "settleAnimations", timeout_ms: "timeoutMS", use_main_content_only: "useMainContentOnly", wait_for_ms: "waitForMs" ), model: ContextDev::Models::WebWebScrapeHTMLResponse, options: ) end |
#web_scrape_images(url:, dedupe: nil, enrichment: nil, headers: nil, max_age_ms: nil, timeout_ms: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeImagesResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeImagesParams for more details.
Extract image assets from a web page, including standard URLs, inline SVGs, data URIs, responsive image sources, metadata, CSS backgrounds, video posters, and embeds. The base request costs 1 credit. When enrichment is enabled, the entire call costs 5 credits.
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/context_dev/resources/web.rb', line 410 def web_scrape_images(params) parsed, = ContextDev::WebWebScrapeImagesParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/scrape/images", query: query.transform_keys( max_age_ms: "maxAgeMs", timeout_ms: "timeoutMS", wait_for_ms: "waitForMs" ), model: ContextDev::Models::WebWebScrapeImagesResponse, options: ) end |
#web_scrape_md(url:, country: nil, exclude_selectors: nil, headers: nil, include_frames: nil, include_images: nil, include_links: nil, include_selectors: nil, max_age_ms: nil, pdf: nil, settle_animations: nil, shorten_base64_images: nil, timeout_ms: nil, use_main_content_only: nil, wait_for_ms: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeMdResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeMdParams for more details.
Scrapes the given URL into LLM usable Markdown.
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 |
# File 'lib/context_dev/resources/web.rb', line 468 def web_scrape_md(params) parsed, = ContextDev::WebWebScrapeMdParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/scrape/markdown", query: query.transform_keys( exclude_selectors: "excludeSelectors", include_frames: "includeFrames", include_images: "includeImages", include_links: "includeLinks", include_selectors: "includeSelectors", max_age_ms: "maxAgeMs", settle_animations: "settleAnimations", shorten_base64_images: "shortenBase64Images", timeout_ms: "timeoutMS", use_main_content_only: "useMainContentOnly", wait_for_ms: "waitForMs" ), model: ContextDev::Models::WebWebScrapeMdResponse, options: ) end |
#web_scrape_sitemap(domain:, headers: nil, max_links: nil, timeout_ms: nil, url_regex: nil, request_options: {}) ⇒ ContextDev::Models::WebWebScrapeSitemapResponse
Some parameter documentations has been truncated, see Models::WebWebScrapeSitemapParams for more details.
Crawl an entire website's sitemap and return all discovered page URLs.
514 515 516 517 518 519 520 521 522 523 524 |
# File 'lib/context_dev/resources/web.rb', line 514 def web_scrape_sitemap(params) parsed, = ContextDev::WebWebScrapeSitemapParams.dump_request(params) query = ContextDev::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "web/scrape/sitemap", query: query.transform_keys(max_links: "maxLinks", timeout_ms: "timeoutMS", url_regex: "urlRegex"), model: ContextDev::Models::WebWebScrapeSitemapResponse, options: ) end |