Class: ContextDev::Resources::Web
- Inherits:
-
Object
- Object
- ContextDev::Resources::Web
- Defined in:
- lib/context_dev/resources/web.rb
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(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(direct_url: nil, domain: nil, full_screenshot: nil, handle_cookie_popup: nil, max_age_ms: nil, page: 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:, exclude_domains: nil, freshness: nil, include_domains: nil, markdown_options: 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:, 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, 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:, exclude_selectors: nil, headers: nil, include_frames: nil, include_selectors: nil, max_age_ms: nil, pdf: 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:, 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:, exclude_selectors: nil, headers: nil, include_frames: nil, include_images: nil, include_links: nil, include_selectors: nil, max_age_ms: nil, pdf: 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.
498 499 500 |
# File 'lib/context_dev/resources/web.rb', line 498 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(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.
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/context_dev/resources/web.rb', line 145 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( direct_url: "directUrl", max_age_ms: "maxAgeMs", timeout_ms: "timeoutMS" ), model: ContextDev::Models::WebExtractStyleguideResponse, options: ) end |
#screenshot(direct_url: nil, domain: nil, full_screenshot: nil, handle_cookie_popup: nil, max_age_ms: nil, page: 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.
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/context_dev/resources/web.rb', line 191 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( direct_url: "directUrl", full_screenshot: "fullScreenshot", handle_cookie_popup: "handleCookiePopup", max_age_ms: "maxAgeMs", timeout_ms: "timeoutMS", wait_for_ms: "waitForMs" ), model: ContextDev::Models::WebScreenshotResponse, options: ) end |
#search(query:, exclude_domains: nil, freshness: nil, include_domains: nil, markdown_options: 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.
236 237 238 239 240 241 242 243 244 245 |
# File 'lib/context_dev/resources/web.rb', line 236 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:, 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, 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.
294 295 296 297 298 299 300 301 302 303 |
# File 'lib/context_dev/resources/web.rb', line 294 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:, exclude_selectors: nil, headers: nil, include_frames: nil, include_selectors: nil, max_age_ms: nil, pdf: 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.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/context_dev/resources/web.rb', line 337 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", timeout_ms: "timeoutMS", use_main_content_only: "useMainContentOnly", wait_for_ms: "waitForMs" ), model: ContextDev::Models::WebWebScrapeHTMLResponse, options: ) end |
#web_scrape_images(url:, 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.
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/context_dev/resources/web.rb', line 384 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:, exclude_selectors: nil, headers: nil, include_frames: nil, include_images: nil, include_links: nil, include_selectors: nil, max_age_ms: nil, pdf: 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.
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/context_dev/resources/web.rb', line 438 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", 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.
483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/context_dev/resources/web.rb', line 483 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 |