Skip to content

Commit

Permalink
New Components - zenscrape (#15467)
Browse files Browse the repository at this point in the history
* new components

* pnpm-lock.yaml

* remove source
  • Loading branch information
michelle0927 authored Feb 5, 2025
1 parent f139761 commit d319f39
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import zenscrape from "../../zenscrape.app.mjs";

export default {
key: "zenscrape-get-credit-status",
name: "Get Credit Status",
description: "Retrieve the number of remaining credits in Zenscrape. [See the documentation](https://app.zenscrape.com/documentation)",
version: "0.0.1",
type: "action",
props: {
zenscrape,
},
async run({ $ }) {
const response = await this.zenscrape.getStatus({
$,
});
$.export("$summary", "Successfully retrieved credit status.");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import zenscrape from "../../zenscrape.app.mjs";

export default {
key: "zenscrape-get-website-content",
name: "Get Website Content",
description: "Retrieve the content of a website. [See the documentation](https://app.zenscrape.com/documentation)",
version: "0.0.1",
type: "action",
props: {
zenscrape,
url: {
propDefinition: [
zenscrape,
"url",
],
},
premium: {
propDefinition: [
zenscrape,
"premium",
],
},
location: {
propDefinition: [
zenscrape,
"location",
],
},
keepHeaders: {
propDefinition: [
zenscrape,
"keepHeaders",
],
},
render: {
propDefinition: [
zenscrape,
"render",
],
},
},
async run({ $ }) {
const response = await this.zenscrape.getContent({
$,
params: {
url: this.url,
premium: this.premium,
location: this.location,
keep_headers: this.keepHeaders,
render: this.render,
},
});
$.export("$summary", `Successfully scraped website \`${this.url}.\``);
return response;
},
};
8 changes: 6 additions & 2 deletions components/zenscrape/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zenscrape",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Zenscrape Components",
"main": "zenscrape.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,9 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3",
"md5": "^2.3.0"
}
}
}
64 changes: 60 additions & 4 deletions components/zenscrape/zenscrape.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,67 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "zenscrape",
propDefinitions: {},
propDefinitions: {
url: {
type: "string",
label: "URL",
description: "The target site you want to scrape",
},
premium: {
type: "boolean",
label: "Premium",
description: "Uses residential proxies, unlocks sites that are hard to scrape. Counts as 20 credits towards your quota.",
optional: true,
},
location: {
type: "string",
label: "Location",
description: "If premium=`false` possible locations are 'na' (North America) and 'eu' (Europe). If premium=`true` you can choose a location from Zenscrape's [list of 230+ countries](https://app.zenscrape.com/documentation#proxyLocationList)",
optional: true,
},
keepHeaders: {
type: "boolean",
label: "Keep Headers",
description: "Allow to pass through forward headers (e.g. user agents, cookies)",
optional: true,
},
render: {
type: "boolean",
label: "Render",
description: "Use a headless browser to fetch content that relies on javascript. Counts as 5 credits towards your quota.",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://app.zenscrape.com/api/v1";
},
_makeRequest({
$ = this,
path,
...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
apikey: this.$auth.api_key,
},
...opts,
});
},
getContent(opts = {}) {
return this._makeRequest({
path: "/get",
...opts,
});
},
getStatus(opts = {}) {
return this._makeRequest({
path: "/status",
...opts,
});
},
},
};
9 changes: 8 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d319f39

Please sign in to comment.