質問編集履歴
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,6 +74,42 @@
|
|
74
74
|
|
75
75
|
```
|
76
76
|
|
77
|
+
### 追加のソースコード
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
```python
|
82
|
+
|
83
|
+
for pokemon in soup.find_all("div", attrs={"class": "ttl-result-area"}):
|
84
|
+
|
85
|
+
detail = {}
|
86
|
+
|
87
|
+
name = pokemon.find("span",attrs={"class": "horizontal-rhythm"}).text.strip()
|
88
|
+
|
89
|
+
ranks = pokemon.find_all("span",attrs={"class": "lbl-ipo-decline"})
|
90
|
+
|
91
|
+
detail = {}
|
92
|
+
|
93
|
+
if len(ranks)>0:
|
94
|
+
|
95
|
+
rank = ranks[0].text
|
96
|
+
|
97
|
+
else:
|
98
|
+
|
99
|
+
rank = ""
|
100
|
+
|
101
|
+
print(f"rank={rank},name={name}")
|
102
|
+
|
103
|
+
detail['ポケモン'] = name
|
104
|
+
|
105
|
+
detail['ランク'] = rank
|
106
|
+
|
107
|
+
#detailの結果
|
108
|
+
|
109
|
+
{'ポケモン': 'キモリ', 'ランク': 'B'}
|
110
|
+
|
111
|
+
```
|
112
|
+
|
77
113
|
|
78
114
|
|
79
115
|
|