Skip to content

Commit 3308015

Browse files
committed
Added actions
1 parent f9a9816 commit 3308015

File tree

3 files changed

+42
-57
lines changed

3 files changed

+42
-57
lines changed

components/scrapingant/actions/general-extraction/general-extraction.mjs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ export default {
1919
app,
2020
"browser",
2121
],
22+
reloadProps: true,
2223
},
2324
returnPageSource: {
2425
propDefinition: [
2526
app,
2627
"returnPageSource",
2728
],
29+
disabled: true,
30+
hidden: true,
2831
},
2932
cookies: {
3033
propDefinition: [
@@ -37,6 +40,8 @@ export default {
3740
app,
3841
"jsSnippet",
3942
],
43+
disabled: true,
44+
hidden: true,
4045
},
4146
proxyType: {
4247
propDefinition: [
@@ -61,8 +66,27 @@ export default {
6166
app,
6267
"blockResource",
6368
],
69+
disabled: true,
70+
hidden: true,
6471
},
6572
},
73+
async additionalProps(existingProps) {
74+
const props = {};
75+
if (this.browser) {
76+
existingProps.returnPageSource.hidden = false;
77+
existingProps.returnPageSource.disabled = false;
78+
}
79+
if (this.browser) {
80+
existingProps.jsSnippet.hidden = false;
81+
existingProps.jsSnippet.disabled = false;
82+
}
83+
if (this.browser) {
84+
existingProps.blockResource.hidden = false;
85+
existingProps.blockResource.disabled = false;
86+
}
87+
return props;
88+
},
89+
6690
async run({ $ }) {
6791
const response = await this.app.generalExtraction({
6892
$,
@@ -78,9 +102,7 @@ export default {
78102
block_resource: this.blockResource,
79103
},
80104
});
81-
82105
$.export("$summary", "Successfully sent the request to ScrapingAnt");
83-
84106
return response;
85107
},
86108
};

components/scrapingant/common/constants.mjs

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -108,57 +108,19 @@ export default {
108108
},
109109
],
110110
RESOURCE_TYPES: [
111-
{
112-
label: "Document",
113-
value: "document",
114-
},
115-
{
116-
label: "Stylesheet",
117-
value: "stylesheet",
118-
},
119-
{
120-
label: "Image",
121-
value: "image",
122-
},
123-
{
124-
label: "Media",
125-
value: "media",
126-
},
127-
{
128-
label: "Font",
129-
value: "font",
130-
},
131-
{
132-
label: "Script",
133-
value: "script",
134-
},
135-
{
136-
label: "Texttrack",
137-
value: "texttrack",
138-
},
139-
{
140-
label: "XHR",
141-
value: "xhr",
142-
},
143-
{
144-
label: "Fetch",
145-
value: "fetch",
146-
},
147-
{
148-
label: "Eventsource",
149-
value: "eventsource",
150-
},
151-
{
152-
label: "Websocket",
153-
value: "websocket",
154-
},
155-
{
156-
label: "Manifest",
157-
value: "manifest",
158-
},
159-
{
160-
label: "Other",
161-
value: "other",
162-
},
111+
"document",
112+
"stylesheet",
113+
"image",
114+
"media",
115+
"font",
116+
"script",
117+
"texttrack",
118+
"xhr",
119+
"fetch",
120+
"eventsource",
121+
"websocket",
122+
"manifest",
123+
"other",
163124
],
125+
164126
};

components/scrapingant/scrapingant.app.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
returnPageSource: {
2020
type: "boolean",
2121
label: "Return Page Source",
22-
description: "Enables returning data returned by the server and unaltered by the browser. Default: false. When true - JS won't be rendered. This feature works only with `browser=true`",
22+
description: "Enables returning data returned by the server and unaltered by the browser. When true JS won't be rendered",
2323
optional: true,
2424
},
2525
cookies: {
@@ -31,7 +31,7 @@ export default {
3131
jsSnippet: {
3232
type: "string",
3333
label: "JS Snippet",
34-
description: "Base64 encoded JS snippet to run once page being loaded in the ScrapingAnt browser. This feature works only with `browser=true`",
34+
description: "Base64 encoded JS snippet to run once page being loaded in the ScrapingAnt browser",
3535
optional: true,
3636
},
3737
proxyType: {
@@ -57,7 +57,8 @@ export default {
5757
blockResource: {
5858
type: "string[]",
5959
label: "Block Resource",
60-
description: "Prevents cloud browser from loading the specified resource types",
60+
description: "Prevents cloud browser from loading specified resource types",
61+
options: constants.RESOURCE_TYPES,
6162
optional: true,
6263
},
6364
},

0 commit comments

Comments
 (0)