Skip to content

Commit 4ce86a4

Browse files
authored
[Components] proxy_spider #10923 (#18927)
* Added actions * Added actions
1 parent 407d8d0 commit 4ce86a4

File tree

6 files changed

+183
-7
lines changed

6 files changed

+183
-7
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import app from "../../proxy_spider.app.mjs";
2+
3+
export default {
4+
key: "proxy_spider-list-proxies",
5+
name: "List Proxies",
6+
description: "List proxies from Proxy Spider. [See the documentation](https://proxy-spider.com/docs/api/public-proxies)",
7+
version: "0.0.1",
8+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
limit: {
17+
propDefinition: [
18+
app,
19+
"limit",
20+
],
21+
},
22+
countryCode: {
23+
propDefinition: [
24+
app,
25+
"countryCode",
26+
],
27+
},
28+
responseTime: {
29+
propDefinition: [
30+
app,
31+
"responseTime",
32+
],
33+
},
34+
protocols: {
35+
propDefinition: [
36+
app,
37+
"protocols",
38+
],
39+
},
40+
type: {
41+
propDefinition: [
42+
app,
43+
"type",
44+
],
45+
},
46+
},
47+
async run({ $ }) {
48+
const response = await this.app.listProxies({
49+
$,
50+
params: {
51+
limit: this.limit,
52+
country_code: this.countryCode?.join(","),
53+
response_time: this.responseTime?.join(","),
54+
protocols: this.protocols?.join(","),
55+
type: this.type?.join(","),
56+
},
57+
});
58+
$.export("$summary", "Successfully sent the request. Retrieved " + response.data.proxies.length + " proxies");
59+
return response;
60+
},
61+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import app from "../../proxy_spider.app.mjs";
2+
3+
export default {
4+
key: "proxy_spider-ping-server",
5+
name: "Ping Server",
6+
description: "Ping Proxy Spider. [See the documentation](https://proxy-spider.com/docs/api/public-proxies)",
7+
version: "0.0.1",
8+
annotations: {
9+
openWorldHint: true,
10+
destructiveHint: false,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
},
17+
async run({ $ }) {
18+
const response = await this.app.pingServer({
19+
$,
20+
});
21+
$.export("$summary", "Successfully sent the request. Status: " + response.status);
22+
return response;
23+
},
24+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default {
2+
TIME_OPTIONS: [
3+
"slow",
4+
"medium",
5+
"fast",
6+
],
7+
PROTOCOLS: [
8+
"http",
9+
"https",
10+
"socks4",
11+
"socks5",
12+
],
13+
TYPES: [
14+
"anonymous",
15+
"elite",
16+
"transparent",
17+
],
18+
};

components/proxy_spider/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/proxy_spider",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Proxy Spider Components",
55
"main": "proxy_spider.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
1518
}
Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
14
export default {
25
type: "app",
36
app: "proxy_spider",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
limit: {
9+
type: "integer",
10+
label: "Limit",
11+
description: "The number of proxies to retrieve, between 1 and 1000",
12+
optional: true,
13+
},
14+
countryCode: {
15+
type: "string[]",
16+
label: "Country Code",
17+
description: "Add this to retrieve only proxies at this location, i.e.: `US`",
18+
optional: true,
19+
},
20+
responseTime: {
21+
type: "string[]",
22+
label: "Response Time",
23+
description: "Add this to retrieve only proxies with a specific response time",
24+
optional: true,
25+
options: constants.TIME_OPTIONS,
26+
},
27+
protocols: {
28+
type: "string[]",
29+
label: "Protocols",
30+
description: "Add this to retrieve only proxies with a specific protocol",
31+
optional: true,
32+
options: constants.PROTOCOLS,
33+
},
34+
type: {
35+
type: "string[]",
36+
label: "Type",
37+
description: "Add this to retrieve only proxies with a type",
38+
optional: true,
39+
options: constants.TYPES,
40+
},
41+
},
542
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
43+
_baseUrl() {
44+
return "https://proxy-spider.com/api";
45+
},
46+
async _makeRequest(opts = {}) {
47+
const {
48+
$ = this,
49+
path,
50+
params,
51+
...otherOpts
52+
} = opts;
53+
return axios($, {
54+
...otherOpts,
55+
url: this._baseUrl() + path,
56+
params: {
57+
api_key: `${this.$auth.api_key}`,
58+
...params,
59+
},
60+
});
61+
},
62+
63+
async listProxies(args = {}) {
64+
return this._makeRequest({
65+
path: "/proxies.json",
66+
...args,
67+
});
68+
},
69+
70+
async pingServer(args = {}) {
71+
return this._makeRequest({
72+
path: "/ping.json",
73+
...args,
74+
});
975
},
1076
},
11-
};
77+
};

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)