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
**In this lesson we'll use ChatGPT and a few commands to create an application for watching prices on an e-commerce website.**
9
12
10
13
---
@@ -62,23 +65,65 @@ You are ready if it prints something like the following:
62
65
apify-cli/0.0.0 (1a2b3c4) running on ... with node-0.0.0, installed via ...
63
66
```
64
67
65
-
## Setting up an Actor template
68
+
## Creating an Actor
66
69
67
-
<!--
68
-
TODO Now let's setup the Actor… Find a suitable folder and run `apify create`
69
-
-->
70
+
Now let's use the Apify CLI to help us kick off a new Actor:
70
71
71
-
:::note Course under construction
72
-
This section hasn't been written yet. Come later, please!
73
-
:::
72
+
```text
73
+
apify create warehouse-scraper
74
+
```
74
75
75
-
## Scraping products
76
+
It starts a wizard where you can choose from various options. For each option, only repeatedly use the <kbd>↵</kbd> key to confirm whatever is set as the first or default:
76
77
77
-
:::note Course under construction
78
-
This section hasn't been written yet. Come later, please!
79
-
:::
78
+
```text
79
+
✔ Choose the programming language of your new Actor: JavaScript
80
+
✔ Choose a template for your new Actor. You can check more information at https://apify.com/templates. Crawlee + Cheerio
81
+
✔ Almost done! Last step is to install dependencies. Install dependencies
82
+
83
+
...
80
84
81
-
## Running code
85
+
Success: ✅ Actor 'warehouse-scraper' created successfully!
86
+
87
+
Next steps:
88
+
89
+
cd "warehouse-scraper"
90
+
apify run
91
+
92
+
💡 Tip: Use 'apify push' to deploy your Actor to the Apify platform
🌱 Git repository initialized in 'warehouse-scraper'. You can now commit and push your Actor to Git.
95
+
```
96
+
97
+
Now that's a lot of output, but no worries, the important part is that we've successfully used a template to set up a new Actor project.
98
+
99
+
A new directory `warehouse-scraper` has been created for us, with a variety of files and directories inside. The output instructs us to go to this new project directory, so let's do it:
100
+
101
+
```
102
+
cd "warehouse-scraper"
103
+
```
104
+
105
+
Now we can run commands which control this new project. We didn't change the template in any way though, so it won't scrape the Warehouse store for us yet.
106
+
107
+
Out of the box, the template implements a sample Actor which walks through the [crawlee.dev](https://crawlee.dev/) website and downloads all of its pages. Such thing is called _crawling_, and Crawlee is a popular tool for crawling which this Actor internally uses. Let's see if it works for us:
108
+
109
+
```
110
+
apify run
111
+
```
112
+
113
+
If you see a flood of output mentioning something called `CheerioCrawler`, it means the template works and we can move on to editing its files so that it does what we want.
114
+
115
+
```text
116
+
...
117
+
INFO CheerioCrawler: Starting the crawler.
118
+
INFO CheerioCrawler: enqueueing new URLs
119
+
INFO CheerioCrawler: Crawlee · Build reliable crawlers. Fast. {"url":"https://crawlee.dev/"}
120
+
...
121
+
INFO CheerioCrawler: Finished! Total 107 requests: 107 succeeded, 0 failed. {"terminal":true}
122
+
```
123
+
124
+
If you struggle to use the template wizard or to run the sample Actor, share this tutorial with [ChatGPT](https://chatgpt.com/), add any errors you've encountered, and see if it can help you debug the issue.
125
+
126
+
## Scraping products
82
127
83
128
<!--
84
129
Save it to the template, setup Node/npm environment, run it, get results. If the student gets stuck setting up Node/npm, they ask ChatGPT. Roughly explaining what the program does, establishing basic terms.
@@ -88,7 +133,7 @@ Save it to the template, setup Node/npm environment, run it, get results. If the
88
133
This section hasn't been written yet. Come later, please!
89
134
:::
90
135
91
-
####Scraping stock units
136
+
## Scraping stock units
92
137
93
138
<!--
94
139
Prompt ChatGPT to modify the program so that it scrapes stock units. Technically, modifying the program like this proves to be cumbersome, but doable. Run the program again, get better results.
0 commit comments