回答編集履歴
1
find・find_allでの書き方を追加
test
CHANGED
@@ -13,6 +13,38 @@
|
|
13
13
|
classの指定方法
|
14
14
|
|
15
15
|
|
16
|
+
|
17
|
+
# findとfind_all
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```python
|
22
|
+
|
23
|
+
for i in soup.find_all("div", class_ = "diagram-result-table"):
|
24
|
+
|
25
|
+
# 時間に分ける
|
26
|
+
|
27
|
+
for j in i.find_all("div", class_ = "table-box"):
|
28
|
+
|
29
|
+
# 時間を取得
|
30
|
+
|
31
|
+
h = j.find("div", class_ = "table-row-title-text").get_text(strip = True)
|
32
|
+
|
33
|
+
# 分を取得
|
34
|
+
|
35
|
+
m = [k.get_text(strip = True) for k in j.find_all("span", class_ = "table-row-item-minutes")]
|
36
|
+
|
37
|
+
print(h, m)
|
38
|
+
|
39
|
+
print("-" * 20)
|
40
|
+
|
41
|
+
```
|
42
|
+
|
43
|
+
# CSSセレクタのselect_oneとselect
|
44
|
+
|
45
|
+
CSSセレクタのほうが書きやすくあと細かく指定しやすいので
|
46
|
+
|
47
|
+
こちらをメインに勉強されるほうがいいです
|
16
48
|
|
17
49
|
```python
|
18
50
|
|