Skip to content

Commit 3c19855

Browse files
authored
New Components - serphouse (#18910)
* new actions * pnpm-lock.yaml * add location instructions
1 parent 718ed0b commit 3c19855

File tree

5 files changed

+389
-7
lines changed

5 files changed

+389
-7
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import serphouse from "../../serphouse.app.mjs";
2+
3+
export default {
4+
key: "serphouse-google-jobs-search",
5+
name: "Google Jobs Search",
6+
description: "Performs a Google Jobs search using the Serphouse API. [See the documentation](https://docs.serphouse.com/google-apis/google-jobs-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
serphouse,
16+
query: {
17+
propDefinition: [
18+
serphouse,
19+
"query",
20+
],
21+
},
22+
domain: {
23+
propDefinition: [
24+
serphouse,
25+
"domain",
26+
() => ({
27+
type: "google",
28+
}),
29+
],
30+
},
31+
language: {
32+
propDefinition: [
33+
serphouse,
34+
"language",
35+
({ domain }) => ({
36+
domain,
37+
}),
38+
],
39+
},
40+
locationAlert: {
41+
propDefinition: [
42+
serphouse,
43+
"locationAlert",
44+
],
45+
},
46+
locationId: {
47+
propDefinition: [
48+
serphouse,
49+
"locationId",
50+
({ domain }) => ({
51+
domain,
52+
}),
53+
],
54+
},
55+
dateRange: {
56+
propDefinition: [
57+
serphouse,
58+
"dateRange",
59+
],
60+
},
61+
},
62+
async run({ $ }) {
63+
const response = await this.serphouse.googleJobsSearch({
64+
$,
65+
data: {
66+
data: {
67+
q: this.query,
68+
domain: this.domain,
69+
lang: this.language,
70+
loc_id: this.locationId,
71+
date_range: this.dateRange,
72+
},
73+
},
74+
});
75+
if (response.status === "success") {
76+
$.export("$summary", `Successfully performed Google Jobs search for "${this.query}".`);
77+
}
78+
return response;
79+
},
80+
};
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import serphouse from "../../serphouse.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "serphouse-perform-search",
6+
name: "Perform Search",
7+
description: "Performs a search using the Serphouse API. [See the documentation](https://docs.serphouse.com/serp-api/live-using-http-get-method)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: false,
12+
openWorldHint: true,
13+
readOnlyHint: true,
14+
},
15+
props: {
16+
serphouse,
17+
query: {
18+
propDefinition: [
19+
serphouse,
20+
"query",
21+
],
22+
},
23+
domain: {
24+
propDefinition: [
25+
serphouse,
26+
"domain",
27+
],
28+
},
29+
language: {
30+
propDefinition: [
31+
serphouse,
32+
"language",
33+
({ domain }) => ({
34+
domain,
35+
}),
36+
],
37+
},
38+
device: {
39+
type: "string",
40+
label: "Device",
41+
description: "The device to use for the search",
42+
options: [
43+
"desktop",
44+
"tablet",
45+
"mobile",
46+
],
47+
},
48+
serpType: {
49+
type: "string",
50+
label: "SERP Type",
51+
description: "The type of SERP to use for the search",
52+
options: [
53+
"web",
54+
"news",
55+
"image",
56+
],
57+
},
58+
locationAlert: {
59+
propDefinition: [
60+
serphouse,
61+
"locationAlert",
62+
],
63+
},
64+
locationId: {
65+
propDefinition: [
66+
serphouse,
67+
"locationId",
68+
({ domain }) => ({
69+
domain,
70+
}),
71+
],
72+
optional: true,
73+
},
74+
verbatim: {
75+
type: "boolean",
76+
label: "Verbatim",
77+
description: "If true, the search will be performed verbatim",
78+
optional: true,
79+
},
80+
gfilter: {
81+
type: "boolean",
82+
label: "GFilter",
83+
description: "Parameter defines if the filters for 'Similar Results' and 'Omitted Results' are on or off. It can be set to `true` (default) to enable these filters, or `false` to disable these filters.",
84+
optional: true,
85+
default: true,
86+
},
87+
page: {
88+
type: "integer",
89+
label: "Page",
90+
description: "Give specific page to get the result of that page number. By default it will get you first page",
91+
optional: true,
92+
},
93+
numResults: {
94+
type: "integer",
95+
label: "Number of Results",
96+
description: "Define number of result you want to get per page. By default you will get top 100 results.",
97+
optional: true,
98+
},
99+
dateRange: {
100+
propDefinition: [
101+
serphouse,
102+
"dateRange",
103+
],
104+
},
105+
},
106+
async run({ $ }) {
107+
const type = this.serphouse.getDomainType(this.domain);
108+
if (!this.locationId && (type === "google" || type === "bing")) {
109+
throw new ConfigurationError("Location is required for Google and Bing searches");
110+
}
111+
const response = await this.serphouse.performSearch({
112+
$,
113+
params: {
114+
q: this.query,
115+
domain: this.domain,
116+
lang: this.language,
117+
device: this.device,
118+
serp_type: this.serpType,
119+
loc_id: this.locationId,
120+
verbatim: this.verbatim
121+
? "1"
122+
: "0",
123+
gfilter: this.gfilter
124+
? "1"
125+
: "0",
126+
page: this.page,
127+
num_result: this.numResults,
128+
date_range: this.dateRange,
129+
},
130+
});
131+
if (response.status === "success") {
132+
$.export("$summary", `Successfully performed search for "${this.query}".`);
133+
}
134+
return response;
135+
},
136+
};

components/serphouse/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/serphouse",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream SERPhouse Components",
55
"main": "serphouse.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
}

0 commit comments

Comments
 (0)