|
| 1 | +namespace Firecrawl; |
| 2 | + |
| 3 | +public partial class ScrapingClient |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// Scrape a single URL and optionally apply scrape options. |
| 7 | + /// </summary> |
| 8 | + /// <param name="url"></param> |
| 9 | + /// <param name="cancellationToken">The token to cancel the operation with</param> |
| 10 | + public Task<ScrapeResponse> ScrapeAndExtractFromUrlAsync( |
| 11 | + Uri url, |
| 12 | + CancellationToken cancellationToken = default) |
| 13 | + { |
| 14 | + ArgumentNullException.ThrowIfNull(url); |
| 15 | + |
| 16 | + return ScrapeAndExtractFromUrlAsync( |
| 17 | + url: url.ToString(), |
| 18 | + cancellationToken: cancellationToken); |
| 19 | + } |
| 20 | + |
| 21 | + /// <summary> |
| 22 | + /// Scrape a single URL and apply the provided scrape options. |
| 23 | + /// </summary> |
| 24 | + /// <param name="url"></param> |
| 25 | + /// <param name="options"></param> |
| 26 | + /// <param name="cancellationToken">The token to cancel the operation with</param> |
| 27 | + public Task<ScrapeResponse> ScrapeAndExtractFromUrlAsync( |
| 28 | + Uri url, |
| 29 | + ScrapeOptions options, |
| 30 | + CancellationToken cancellationToken = default) |
| 31 | + { |
| 32 | + ArgumentNullException.ThrowIfNull(url); |
| 33 | + |
| 34 | + return ScrapeAndExtractFromUrlAsync( |
| 35 | + url: url.ToString(), |
| 36 | + options: options, |
| 37 | + cancellationToken: cancellationToken); |
| 38 | + } |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// Scrape a single URL and optionally apply scrape options. |
| 42 | + /// </summary> |
| 43 | + /// <param name="url"></param> |
| 44 | + /// <param name="cancellationToken">The token to cancel the operation with</param> |
| 45 | + public Task<ScrapeResponse> ScrapeAndExtractFromUrlAsync( |
| 46 | + string url, |
| 47 | + CancellationToken cancellationToken = default) |
| 48 | + { |
| 49 | + ArgumentException.ThrowIfNullOrWhiteSpace(url); |
| 50 | + |
| 51 | + return ScrapeAndExtractFromUrlAsync( |
| 52 | + request: new AllOf<ScrapeAndExtractFromUrlRequest2, ScrapeOptions>( |
| 53 | + new ScrapeAndExtractFromUrlRequest2 |
| 54 | + { |
| 55 | + Url = url, |
| 56 | + }, |
| 57 | + new ScrapeOptions()), |
| 58 | + cancellationToken: cancellationToken); |
| 59 | + } |
| 60 | + |
| 61 | + /// <summary> |
| 62 | + /// Scrape a single URL and apply the provided scrape options. |
| 63 | + /// </summary> |
| 64 | + /// <param name="url"></param> |
| 65 | + /// <param name="options"></param> |
| 66 | + /// <param name="cancellationToken">The token to cancel the operation with</param> |
| 67 | + public Task<ScrapeResponse> ScrapeAndExtractFromUrlAsync( |
| 68 | + string url, |
| 69 | + ScrapeOptions options, |
| 70 | + CancellationToken cancellationToken = default) |
| 71 | + { |
| 72 | + ArgumentException.ThrowIfNullOrWhiteSpace(url); |
| 73 | + ArgumentNullException.ThrowIfNull(options); |
| 74 | + |
| 75 | + return ScrapeAndExtractFromUrlAsync( |
| 76 | + request: new AllOf<ScrapeAndExtractFromUrlRequest2, ScrapeOptions>( |
| 77 | + new ScrapeAndExtractFromUrlRequest2 |
| 78 | + { |
| 79 | + Url = url, |
| 80 | + }, |
| 81 | + options), |
| 82 | + cancellationToken: cancellationToken); |
| 83 | + } |
| 84 | +} |
0 commit comments