File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
sources/academy/webscraping/scraping_basics_javascript2 Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -237,13 +237,13 @@ async function download(url) {
237
237
}
238
238
239
239
function parseProduct (productItem , baseURL ) {
240
- const title = productItem .find (" .product-item__title" );
241
- const titleText = title .text ().trim ();
242
- const url = new URL (title .attr (" href" ), baseURL).href ;
240
+ const $ title = $ productItem .find (" .product-item__title" );
241
+ const title = $ title .text ().trim ();
242
+ const url = new URL ($ title .attr (" href" ), baseURL).href ;
243
243
244
- const price = productItem .find (" .price" ).contents ().last ();
244
+ const $ price = $ productItem .find (" .price" ).contents ().last ();
245
245
const priceRange = { minPrice: null , price: null };
246
- const priceText = price
246
+ const priceText = $ price
247
247
.text ()
248
248
.trim ()
249
249
.replace (" $" , " " )
@@ -257,7 +257,7 @@ function parseProduct(productItem, baseURL) {
257
257
priceRange .price = priceRange .minPrice ;
258
258
}
259
259
260
- return { url, title: titleText , ... priceRange };
260
+ return { url, title, ... priceRange };
261
261
}
262
262
263
263
async function exportJSON (data ) {
You can’t perform that action at this time.
0 commit comments