@pipedream/webscrape_ai 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,75 @@
1
+ import webscrapeAi from "../../webscrape_ai.app.mjs";
2
+
3
+ export default {
4
+ key: "webscrape_ai-scrape-website",
5
+ name: "Scrape Website",
6
+ description: "Scrape the provided URL and store the results in the system. [See the documentation](https://webscrapeai.com/docs)",
7
+ version: "0.0.3",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: false,
12
+ },
13
+ type: "action",
14
+ ai: "optimized",
15
+ props: {
16
+ webscrapeAi,
17
+ alert: {
18
+ type: "alert",
19
+ alertType: "info",
20
+ content: "This actions sends a synchronous request to the WebScrapeAI API and may require increasing the workflow's default timeout.",
21
+ },
22
+ url: {
23
+ type: "string",
24
+ label: "URL",
25
+ description: "The URL of the website to scrape",
26
+ },
27
+ command: {
28
+ type: "string",
29
+ label: "Command",
30
+ description: "The data you want to extract. E.g. `I want to extract all the news details`",
31
+ },
32
+ schema: {
33
+ type: "string",
34
+ label: "Schema",
35
+ description: "Schema representing the fields you want to scrape. E.g. `{\"author\":\"string\",\"comments_count\":\"integer\",\"points\":\"integer\",\"posted_time\":\"string\",\"title\":\"string\",\"url\":\"url\"}`",
36
+ },
37
+ pages: {
38
+ type: "integer",
39
+ label: "Pages",
40
+ description: "Number of pages to scrape. Default value is 1.",
41
+ optional: true,
42
+ },
43
+ headers: {
44
+ type: "string",
45
+ label: "Headers",
46
+ description: "List of headers in key-value pairs. i.e `Accept: application/json`",
47
+ optional: true,
48
+ },
49
+ instructions: {
50
+ type: "string",
51
+ label: "Instructions",
52
+ description: "List of JavaScript instructions that you want to execute, like clicking a specific button, waiting for a specific code block to appear, etc. Example: `{\"click\": \"#button_id\"}`. [See the documentation](https://webscrapeai.com/docs) for more information.",
53
+ optional: true,
54
+ },
55
+ },
56
+ async run({ $ }) {
57
+ const response = await this.webscrapeAi.scrapeWebsite({
58
+ $,
59
+ params: {
60
+ url: this.url,
61
+ command: this.command,
62
+ schema: typeof this.schema === "object"
63
+ ? JSON.stringify(this.schema)
64
+ : this.schema,
65
+ pages: this.pages,
66
+ headers: this.headers,
67
+ instructions: this.instructions,
68
+ },
69
+ });
70
+ $.export("$summary", `Scraped ${this.url} and got ${response.length} result${response.length === 1
71
+ ? ""
72
+ : "s"}`);
73
+ return response;
74
+ },
75
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/webscrape_ai",
3
- "version": "0.0.1",
3
+ "version": "0.1.1",
4
4
  "description": "Pipedream Webscrape AI Components",
5
5
  "main": "webscrape_ai.app.mjs",
6
6
  "keywords": [
@@ -11,5 +11,8 @@
11
11
  "author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
12
12
  "publishConfig": {
13
13
  "access": "public"
14
+ },
15
+ "dependencies": {
16
+ "@pipedream/platform": "^3.1.1"
14
17
  }
15
18
  }
@@ -1,11 +1,30 @@
1
+ import { axios } from "@pipedream/platform";
2
+
1
3
  export default {
2
4
  type: "app",
3
5
  app: "webscrape_ai",
4
6
  propDefinitions: {},
5
7
  methods: {
6
- // this.$auth contains connected account data
7
- authKeys() {
8
- console.log(Object.keys(this.$auth));
8
+ _baseUrl() {
9
+ return "https://api.webscrapeai.com";
10
+ },
11
+ _makeRequest({
12
+ $ = this, path, params, ...opts
13
+ }) {
14
+ return axios($, {
15
+ url: `${this._baseUrl()}${path}`,
16
+ params: {
17
+ ...params,
18
+ apiKey: `${this.$auth.api_key}`,
19
+ },
20
+ ...opts,
21
+ });
22
+ },
23
+ scrapeWebsite(opts = {}) {
24
+ return this._makeRequest({
25
+ path: "/scrapeWebSite",
26
+ ...opts,
27
+ });
9
28
  },
10
29
  },
11
- };
30
+ };