Skip to content

Commit 63288f6

Browse files
authored
fix: a few small fixes in both Python and JS courses for beginners (#1877)
A mixed bag of indentation, wording, etc.
1 parent 476ecc9 commit 63288f6

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

sources/academy/webscraping/scraping_basics_javascript2/13_platform.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ Now let's connect this file to the actor configuration. In `actor.json`, we'll a
231231
"version": "0.0",
232232
"buildTag": "latest",
233233
"environmentVariables": {},
234-
// highlight-next-line
235-
"input": "./inputSchema.json"
234+
// highlight-next-line
235+
"input": "./inputSchema.json"
236236
}
237237
```
238238

sources/academy/webscraping/scraping_basics_python/08_saving_data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ for product in soup.select(".product-item"):
6565
print(data)
6666
```
6767

68-
Before looping over the products, we prepare an empty list. Then, instead of printing each line, we append the data of each product to the list in the form of a Python dictionary. At the end of the program, we print the entire list at once.
68+
Before looping over the products, we prepare an empty list. Then, instead of printing each line, we append the data of each product to the list in the form of a Python dictionary. At the end of the program, we print the entire list. The program should now print the results as a single large Python list:
6969

7070
```text
7171
$ python main.py

sources/academy/webscraping/scraping_basics_python/09_getting_links.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def parse_product(product):
111111
return {"title": title, "min_price": min_price, "price": price}
112112
```
113113

114-
Now the JSON export. For better readability of it, let's make a small change here and set the indentation level to two spaces:
114+
Now the JSON export. For better readability, let's make a small change here and set the indentation level to two spaces:
115115

116116
```py
117117
def export_json(file, data):

sources/academy/webscraping/scraping_basics_python/10_crawling.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Depending on what's valuable for our use case, we can now use the same technique
120120
It looks like using a CSS selector to locate the element with the `product-meta__vendor` class, and then extracting its text, should be enough to get the vendor name as a string:
121121

122122
```py
123-
vendor = product_soup.select_one(".product-meta__vendor").text.strip()
123+
vendor = soup.select_one(".product-meta__vendor").text.strip()
124124
```
125125

126126
But where do we put this line in our program?
@@ -130,8 +130,6 @@ But where do we put this line in our program?
130130
In the `data` loop we're already going through all the products. Let's expand it to include downloading the product detail page, parsing it, extracting the vendor's name, and adding it as a new key in the item's dictionary:
131131

132132
```py
133-
...
134-
135133
listing_url = "https://warehouse-theme-metal.myshopify.com/collections/sales"
136134
listing_soup = download(listing_url)
137135

@@ -143,8 +141,6 @@ for product in listing_soup.select(".product-item"):
143141
# highlight-next-line
144142
item["vendor"] = product_soup.select_one(".product-meta__vendor").text.strip()
145143
data.append(item)
146-
147-
...
148144
```
149145

150146
If we run the program now, it'll take longer to finish since it's making 24 more HTTP requests. But in the end, it should produce exports with a new field containing the vendor's name:
@@ -172,7 +168,7 @@ If we run the program now, it'll take longer to finish since it's making 24 more
172168

173169
## Extracting price
174170

175-
Scraping the vendor's name is nice, but the main reason we started checking the detail pages in the first place was to figure out how to get a price for each product. From the product listing, we could only scrape the min price, and remember—were building a Python app to track prices!
171+
Scraping the vendor's name is nice, but the main reason we started checking the detail pages in the first place was to figure out how to get a price for each product. From the product listing, we could only scrape the min price, and remember—we're building a Python app to track prices!
176172

177173
Looking at the [Sony XBR-950G BRAVIA](https://warehouse-theme-metal.myshopify.com/products/sony-xbr-65x950g-65-class-64-5-diag-bravia-4k-hdr-ultra-hd-tv), it's clear that the listing only shows min prices, because some products have variants, each with a different price. And different stock availability. And different SKUs…
178174

0 commit comments

Comments
 (0)