回答編集履歴

2

soupをelementsに

2020/07/07 23:52

投稿

Penpen7
Penpen7

スコア698

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  ```python
22
22
 
23
- nurseries=soup.find_all("a")
23
+ nurseries=elements.find_all("a")
24
24
 
25
25
  for nursery in nurseries[:min(3, len(nurseries)-1)]:
26
26
 

1

スライス追加

2020/07/07 23:52

投稿

Penpen7
Penpen7

スコア698

test CHANGED
@@ -15,3 +15,17 @@
15
15
  urls.append(nursery.get('href'))
16
16
 
17
17
  ```
18
+
19
+ もしくはスライスとかですかね
20
+
21
+ ```python
22
+
23
+ nurseries=soup.find_all("a")
24
+
25
+ for nursery in nurseries[:min(3, len(nurseries)-1)]:
26
+
27
+ names.append(nursery.get_text())
28
+
29
+ urls.append(nursery.get('href'))
30
+
31
+ ```