|
| 1 | +import firecrawl from "../../firecrawl.app.mjs"; |
| 2 | + |
| 3 | +export default { |
| 4 | + key: "firecrawl-search", |
| 5 | + name: "Search", |
| 6 | + description: "Search the web and get full content from results. [See the documentation](https://docs.firecrawl.dev/features/search)", |
| 7 | + version: "0.0.1", |
| 8 | + type: "action", |
| 9 | + props: { |
| 10 | + firecrawl, |
| 11 | + query: { |
| 12 | + type: "string", |
| 13 | + label: "Query", |
| 14 | + description: "The query to search for", |
| 15 | + }, |
| 16 | + scrapeOptionFormats: { |
| 17 | + type: "string[]", |
| 18 | + label: "Scrape Option Formats", |
| 19 | + description: "Search with content scraping. You can specify multiple output formats.", |
| 20 | + options: [ |
| 21 | + { |
| 22 | + label: "Clean, formatted markdown content", |
| 23 | + value: "markdown", |
| 24 | + }, |
| 25 | + { |
| 26 | + label: "Processed HTML content", |
| 27 | + value: "html", |
| 28 | + }, |
| 29 | + { |
| 30 | + label: "Unmodified HTML content", |
| 31 | + value: "rawHtml", |
| 32 | + }, |
| 33 | + { |
| 34 | + label: "List of links found on the page", |
| 35 | + value: "links", |
| 36 | + }, |
| 37 | + { |
| 38 | + label: "Screenshot of the page", |
| 39 | + value: "screenshot", |
| 40 | + }, |
| 41 | + { |
| 42 | + label: "Full-page screenshot", |
| 43 | + value: "screenshot@fullPage", |
| 44 | + }, |
| 45 | + { |
| 46 | + label: "Structured data extraction", |
| 47 | + value: "extract", |
| 48 | + }, |
| 49 | + ], |
| 50 | + optional: true, |
| 51 | + }, |
| 52 | + timeBasedSearch: { |
| 53 | + type: "string", |
| 54 | + label: "Time Based Search", |
| 55 | + description: "Filter the results by time", |
| 56 | + options: [ |
| 57 | + { |
| 58 | + label: "Past hour", |
| 59 | + value: "qdr:h", |
| 60 | + }, |
| 61 | + { |
| 62 | + label: "Past 24 hours", |
| 63 | + value: "qdr:d", |
| 64 | + }, |
| 65 | + { |
| 66 | + label: "Past week", |
| 67 | + value: "qdr:w", |
| 68 | + }, |
| 69 | + { |
| 70 | + label: "Past month", |
| 71 | + value: "qdr:m", |
| 72 | + }, |
| 73 | + { |
| 74 | + label: "Past year", |
| 75 | + value: "qdr:y", |
| 76 | + }, |
| 77 | + ], |
| 78 | + optional: true, |
| 79 | + }, |
| 80 | + customTimeout: { |
| 81 | + type: "integer", |
| 82 | + label: "Custom Timeout", |
| 83 | + description: "Set a custom timeout for search operations. E.g. `30000`", |
| 84 | + optional: true, |
| 85 | + }, |
| 86 | + maxResults: { |
| 87 | + type: "integer", |
| 88 | + label: "Max Results", |
| 89 | + description: "The maximum number of results to return", |
| 90 | + default: 10, |
| 91 | + optional: true, |
| 92 | + }, |
| 93 | + }, |
| 94 | + async run({ $ }) { |
| 95 | + const results = await this.firecrawl.search({ |
| 96 | + $, |
| 97 | + data: { |
| 98 | + query: this.query, |
| 99 | + limit: this.maxResults, |
| 100 | + scrapeOptions: this.scrapeOptionFormats |
| 101 | + ? { |
| 102 | + formats: this.scrapeOptionFormats, |
| 103 | + } |
| 104 | + : undefined, |
| 105 | + tbs: this.timeBasedSearch, |
| 106 | + timeout: this.customTimeout, |
| 107 | + }, |
| 108 | + }); |
| 109 | + $.export("$summary", `Successfully searched for ${this.query}`); |
| 110 | + return results; |
| 111 | + }, |
| 112 | +}; |
0 commit comments