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
Copy file name to clipboardExpand all lines: content/manipulation/04_webscraping/_exo2b.qmd
+19-17Lines changed: 19 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -5,21 +5,21 @@
5
5
Pour récupérer les informations, le code devra être divisé en plusieurs étapes :
6
6
7
7
8
-
1. Trouvez la page principale du site et la transformer en un objet intelligible pour votre code.
9
-
Les fonctions suivantes vous seront utiles :
10
-
-`urllib.request.Request`
11
-
-`urllib.request.urlopen`
8
+
1. Trouvez la page principale du site et la transformer en un objet intelligible pour votre code. Les fonctions suivantes vous seront utiles :
9
+
10
+
-`requests.get`
12
11
-`bs4.BeautifulSoup`
13
12
14
-
2.Créez une fonction qui permet de récupérer la page d'un pokémon à partir de son nom.
13
+
2.A partir de ce code, créer une fonction qui permet de récupérer le copntenu page d'un pokémon à partir de son nom. Vous pouvez nommer cette fonction `get_name`.
15
14
16
15
3. À partir de la page de `bulbasaur`, obtenez les 4 tableaux qui nous intéressent :
16
+
17
17
- on va chercher l'élément suivant : `('table', { 'class' : "vitals-table"})`
18
18
- puis stocker ses éléments dans un dictionnaire
19
19
20
20
4. Récupérez par ailleurs la liste de noms des pokémons qui nous permettra de faire une boucle par la suite. Combien trouvez-vous de pokémons ?
21
21
22
-
5. Écrivez une fonction qui récupère l'ensemble des informations sur les dix premiers pokémons de la liste et les intègre dans un `DataFrame`
22
+
5. Écrivez une fonction qui récupère l'ensemble des informations sur les dix premiers pokémons de la liste et les intègre dans un `DataFrame`.
23
23
24
24
::::
25
25
:::
@@ -28,24 +28,26 @@ Pour récupérer les informations, le code devra être divisé en plusieurs éta
28
28
:::: {.callout-tip}
29
29
## Exercise 2b: Pokémon (guided version)
30
30
31
-
To retrieve the information, the code will need to be divided into several steps:
31
+
To retrieve the information, the code must be divided into several steps:
32
32
33
+
1. Find the site's main page and transform it into an intelligible object for your code. The following functions will be useful:
33
34
34
-
1. Find the main page of the site and transform it into an intelligible object for your code.
35
-
The following functions will be useful:
36
-
-`urllib.request.Request`
37
-
-`urllib.request.urlopen`
35
+
-`requests.get`
38
36
-`bs4.BeautifulSoup`
39
37
40
-
2.Create a function that retrieves a Pokémon's page based on its name.
38
+
2.From this code, create a function that retrieves a pokémon's page content from its name. You can name this function `get_name`.
41
39
42
-
3. From the `bulbasaur` page, obtain the 4 tables we are interested in:
43
-
-We will look for the following element: `('table', { 'class' : "vitals-table"})`
44
-
-Then store its elements in a dictionary
40
+
3. From the `bulbasaur` page, obtain the 4 arrays we're interested in:
41
+
- look for the following element: `(‘table’, { ‘class’ : “vitals-table”})`
42
+
-then store its elements in a dictionary
45
43
46
-
4.Additionally, retrieve the list of Pokémon names that will allow us to loop through later. How many Pokémon do you find?
44
+
4.Retrieve the list of pokemon names, which will enable us to loop later. How many pokémons can you find?
47
45
48
-
5. Write a function that retrieves all the information on the first ten Pokémon in the list and integrates it into a `DataFrame`.
46
+
5. Write a function that retrieves all the information on the first ten pokémons in the list and integrates it into a `DataFrame`.
0 commit comments