質問編集履歴
1
例外が存在する。
test
CHANGED
File without changes
|
test
CHANGED
@@ -123,3 +123,113 @@
|
|
123
123
|
ddd[1].string
|
124
124
|
|
125
125
|
と書いても何も表示されないです。
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
図鑑リストからリンクさせて表示させるようなコードを書いて実行したら
|
130
|
+
|
131
|
+
このページだけ
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
from bs4 import BeautifulSoup
|
136
|
+
|
137
|
+
import urllib.request as req
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
url= "https://yakkun.com/swsh/zukan/n421"
|
142
|
+
|
143
|
+
html = req.urlopen(url)
|
144
|
+
|
145
|
+
parse_html = BeautifulSoup(html,'html.parser')
|
146
|
+
|
147
|
+
table = parse_html.find(class_="table layout_right")
|
148
|
+
|
149
|
+
for tr in table.find_all('tr'):
|
150
|
+
|
151
|
+
if '種族値' in tr.text:
|
152
|
+
|
153
|
+
title = tr.text
|
154
|
+
|
155
|
+
print(title)
|
156
|
+
|
157
|
+
hitpoint = tr.find_next_sibling()
|
158
|
+
|
159
|
+
attack = hitpoint.find_next_sibling()
|
160
|
+
|
161
|
+
defence = attack.find_next_sibling()
|
162
|
+
|
163
|
+
special_attack = defence.find_next_sibling()
|
164
|
+
|
165
|
+
special_defence = special_attack.find_next_sibling()
|
166
|
+
|
167
|
+
speed = special_defence.find_next_sibling()
|
168
|
+
|
169
|
+
average = speed.find_next_sibling()
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
print(hitpoint.text.split())
|
174
|
+
|
175
|
+
print(attack.text.split())
|
176
|
+
|
177
|
+
print(defence.text.split())
|
178
|
+
|
179
|
+
print(special_attack.text.split())
|
180
|
+
|
181
|
+
print(special_defence.text.split())
|
182
|
+
|
183
|
+
print(speed.text.split())
|
184
|
+
|
185
|
+
print(average.text.split())
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
実行すると
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
◆ チェリムの種族値
|
194
|
+
|
195
|
+
['HP', '70']
|
196
|
+
|
197
|
+
['こうげき', '60']
|
198
|
+
|
199
|
+
['ぼうぎょ', '70']
|
200
|
+
|
201
|
+
['とくこう', '87']
|
202
|
+
|
203
|
+
['とくぼう', '78']
|
204
|
+
|
205
|
+
['すばやさ', '85']
|
206
|
+
|
207
|
+
['平均', '/', '合計', '75.0', '/', '450']
|
208
|
+
|
209
|
+
フラワーギフト天気が『にほんばれ』の時、ポジフォルムにフォルムチェンジする。種族値などは変わらないが、自分とすべての味方の『こうげき』『とくぼう』が1.5倍になる。
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
と表示され
|
214
|
+
|
215
|
+
AttributeError Traceback (most recent call last)
|
216
|
+
|
217
|
+
<ipython-input-4-ed11b57b4eb5> in <module>
|
218
|
+
|
219
|
+
8 special_attack = defence.find_next_sibling()
|
220
|
+
|
221
|
+
9 special_defence = special_attack.find_next_sibling()
|
222
|
+
|
223
|
+
---> 10 speed = special_defence.find_next_sibling()
|
224
|
+
|
225
|
+
11 average = speed.find_next_sibling()
|
226
|
+
|
227
|
+
12
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
AttributeError: 'NoneType' object has no attribute 'find_next_sibling'
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
エラーになります。このページだけ他と違う理由がわからないです。
|