You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (!acc[curr.asin] || prevPrice > price) acc[curr.asin] = curr;
115
+
116
+
return acc;
117
+
}, {});
113
118
114
-
return acc;
115
-
}, {});
119
+
awaitActor.pushData(Object.values(filtered));
116
120
117
-
awaitApify.pushData(Object.values(filtered));
118
-
});
121
+
awaitActor.exit();
119
122
```
120
123
121
124
Cool! But **wait**, don't forget to configure the **INPUT_SCHEMA.json** file as well! It's not necessary to do this step, as we'll be calling the actor through Apify's API within a webhook, but it's still good to get into the habit of writing quality input schemas that describe the input values your actors are expecting.
@@ -185,7 +188,7 @@ Additionally, we should be able to see that our **filter-actor** was run, and ha
185
188
186
189
**Q: Within itself, can you get the exact time that an actor was started?**
187
190
188
-
**A:** Yes. The time the actor was started can be retrieved through the `startedAt` property from the `Apify.getEnv()` function, or directly from `process.env.APIFY_STARTED_AT`
191
+
**A:** Yes. The time the actor was started can be retrieved through the `startedAt` property from the `Actor.getEnv()` function, or directly from `process.env.APIFY_STARTED_AT`
189
192
190
193
**Q: What are the types of default storages connected to an actor's run?**
Copy file name to clipboardExpand all lines: content/academy/expert_scraping_with_apify/solutions/using_storage_creating_tasks.md
+82-93Lines changed: 82 additions & 93 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,49 +12,50 @@ Last lesson, our task was outlined for us. In this lesson, we'll be completing t
12
12
13
13
## [](#using-named-dataset) Using a named dataset
14
14
15
-
Something important to understand is that, in the Apify SDK, when you use `Apify.pushData()`, the data will always be pushed to the default dataset. To open up a named dataset, we'll use the `Apify.openDataset()` function:
15
+
Something important to understand is that, in the Apify SDK, when you use `Actor.pushData()`, the data will always be pushed to the default dataset. To open up a named dataset, we'll use the `Actor.openDataset()` function:
16
16
17
17
```JavaScript
18
18
// main.js
19
-
Apify.main(async () => {
20
-
const { keyword } =awaitApify.getInput();
19
+
// ...
20
+
21
+
awaitActor.init()
22
+
23
+
const { keyword } =awaitActor.getInput();
21
24
22
-
// Open a dataset with a custom named based on the
If we remember correctly, we are pushing data to the dataset in the `handleOffers()` function we created in **routes.js**. Let's pass the `dataset` variable pointing to our named dataset into `handleOffers()` as an argument:
31
+
If we remember correctly, we are pushing data to the dataset in the `labels.OFFERS` handler we created in **routes.js**. Let's export the `dataset` variable pointing to our named dataset so we can import it in **routes.js** and use it in the handler:
// Set the "CHEAPEST-ITEM" key in the key-value store to be the
78
81
// newly discovered cheapest item
79
-
awaitApify.setValue(CHEAPEST_ITEM, cheapest);
82
+
awaitActor.setValue(CHEAPEST_ITEM, cheapest);
83
+
84
+
awaitActor.exit();
80
85
```
81
86
82
87
> If you start receiving a linting error after adding the following code to your **main.js** file, add `"parserOptions": { "ecmaVersion":"latest" }` to the **.eslintrc** file in the root directory of your project.
@@ -85,19 +90,17 @@ You might have noticed that we are using a variable instead of a string for the
0 commit comments