Skip to content

Commit 37bff14

Browse files
committed
updates
1 parent 8824f5d commit 37bff14

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

components/browserless/actions/scrape-url-list/scrape-url-list.mjs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,18 @@ export default {
2828
}
2929

3030
const result = {};
31-
const promises = [];
3231

3332
for (const url of this.urls) {
34-
promises.push(this.browserless.scrape({
33+
const response = await this.browserless.scrape({
3534
$,
3635
data: {
3736
url,
3837
elements: this.selectors?.map((selector) => ({
3938
selector,
4039
})),
4140
},
42-
}));
43-
}
44-
45-
const responses = await Promise.all(promises);
46-
for (let i = 0; i < promises.length; i++) {
47-
result[this.urls[i]] = responses[i].data[0].results[0].text;
41+
});
42+
result[url] = response.data[0].results[0].text;
4843
}
4944

5045
return result;

components/browserless/actions/take-screenshot/take-screenshot.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export default {
2020
description: "Download the screenshot to the `/tmp` directory with the specified filename",
2121
optional: true,
2222
},
23-
waitFor: {
23+
waitForSelector: {
2424
type: "string",
25-
label: "waitFor",
26-
description: "Allows you to wait for a selector to appear in the DOM, to wait for a timeout to happen, or to execute a custom function before screenshotting. See [more details in the API Doc](https://www.browserless.io/docs/screenshot#custom-behavior-with-waitfor)",
25+
label: "Selector",
26+
description: "Allows you to wait for a selector to appear in the DOM. See [more details in the API Doc](https://www.browserless.io/docs/screenshot#custom-behavior-with-waitfor)",
2727
optional: true,
2828
},
2929
syncDir: {
@@ -45,9 +45,9 @@ export default {
4545
const screenshot = await this.browserless.takeScreenshot({
4646
data: {
4747
url: this.url,
48-
waitFor: !isNaN(this.waitFor)
49-
? parseInt(this.waitFor)
50-
: this.waitFor,
48+
waitForSelector: this.waitForSelector
49+
? `{ "selector": "${this.waitForSelector}" }`
50+
: undefined,
5151
},
5252
$,
5353
});

components/browserless/browserless.app.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { axios } from "@pipedream/platform";
2+
import { ConfigurationError } from "@pipedream/platform";
23

34
export default {
45
type: "app",
56
app: "browserless",
67
propDefinitions: {},
78
methods: {
89
_baseUrl() {
10+
if (!this.$auth.base_url) {
11+
throw new ConfigurationError("Please reconnect your Browserless account because there are recent changes in Browserless API");
12+
}
913
return `https://${this.$auth.base_url}`;
1014
},
1115
_auth() {

0 commit comments

Comments
 (0)