Skip to content

Commit 9b08749

Browse files
committed
feat: add fandom exercise
1 parent ae8f8eb commit 9b08749

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

sources/academy/webscraping/scraping_basics_python/03_devtools_extracting_data.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To figure out how to get the price, we'll use the **Elements** tab of DevTools a
5858

5959
![Finding child elements](./images/devtools-product-details.png)
6060

61-
We could either rely on the fact that the sale price is likely to be always the one which is highlighted, or that it's always the first price. For now we'll rely on the former and we'll let `querySelector()` to simply return the first result:
61+
We could either rely on the fact that the sale price is likely to be always the one which is highlighted, or that it's always the first price. For now we'll rely on the later and we'll let `querySelector()` to simply return the first result:
6262

6363
```js
6464
price = subwoofer.querySelector('.price');
@@ -69,16 +69,30 @@ It works, but the price isn't alone in the result. Before we'd use such data, we
6969

7070
![Extracting product price](./images/devtools-extracting-price.png)
7171

72-
But for now that's okay. We're just testing the waters now, so that we have an idea about what our scraper will need to do. Once we'll get to extracting prices in Python, we'll figure out how to get numbers out of them.
72+
But for now that's okay. We're just testing the waters now, so that we have an idea about what our scraper will need to do. Once we'll get to extracting prices in Python, we'll figure out how to get the values as numbers.
7373

7474
In the next lesson, we'll start with our Python project. First we'll be figuring out how to download the Sales page without browser and make it accessible in a Python program.
7575

7676
---
7777

7878
<Exercises />
7979

80-
:::danger Work in Progress
80+
### Locate the top Movies wiki on Fandom
8181

82-
Under development.
82+
On Fandom's [Movies page](https://www.fandom.com/topics/movies), use CSS selectors and HTML elements manipulation in the **Console** to extract the name of the top wiki. Use JavaScript's [`trim()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) method to remove white space from around the name.
8383

84-
:::
84+
![Fandom's Movies page](./images/devtools-exercise-fandom.png)
85+
86+
<details>
87+
<summary>Solution</summary>
88+
89+
1. Open the [Movies page](https://www.fandom.com/topics/movies).
90+
1. Activate the element selection tool in your DevTools.
91+
1. Click on the list item for the top Fandom wiki in the category.
92+
1. Notice that it has a class `topic_explore-wikis__link`.
93+
1. In the **Console**, execute `document.querySelector('.topic_explore-wikis__link')`. It returns element representing the top list item. The selector is apparently used only for the **Top Wikis** list, and because `document.querySelector()` returns the first matching element, we're almost done.
94+
1. In the **Console**, execute `item = document.querySelector('.topic_explore-wikis__link')` to save the element in a variable.
95+
1. In the **Console**, execute `item.textContent.trim()` to get the element's text without white space.
96+
1. At the time of writing, this returns `"Pixar Wiki"`.
97+
98+
</details>
673 KB
Loading

0 commit comments

Comments
 (0)