質問編集履歴
1
例外が存在する。
title
CHANGED
File without changes
|
body
CHANGED
@@ -60,4 +60,59 @@
|
|
60
60
|
|
61
61
|
ddd = aaa.find_all(class_="left")
|
62
62
|
ddd[1].string
|
63
|
-
と書いても何も表示されないです。
|
63
|
+
と書いても何も表示されないです。
|
64
|
+
|
65
|
+
図鑑リストからリンクさせて表示させるようなコードを書いて実行したら
|
66
|
+
このページだけ
|
67
|
+
|
68
|
+
from bs4 import BeautifulSoup
|
69
|
+
import urllib.request as req
|
70
|
+
|
71
|
+
url= "https://yakkun.com/swsh/zukan/n421"
|
72
|
+
html = req.urlopen(url)
|
73
|
+
parse_html = BeautifulSoup(html,'html.parser')
|
74
|
+
table = parse_html.find(class_="table layout_right")
|
75
|
+
for tr in table.find_all('tr'):
|
76
|
+
if '種族値' in tr.text:
|
77
|
+
title = tr.text
|
78
|
+
print(title)
|
79
|
+
hitpoint = tr.find_next_sibling()
|
80
|
+
attack = hitpoint.find_next_sibling()
|
81
|
+
defence = attack.find_next_sibling()
|
82
|
+
special_attack = defence.find_next_sibling()
|
83
|
+
special_defence = special_attack.find_next_sibling()
|
84
|
+
speed = special_defence.find_next_sibling()
|
85
|
+
average = speed.find_next_sibling()
|
86
|
+
|
87
|
+
print(hitpoint.text.split())
|
88
|
+
print(attack.text.split())
|
89
|
+
print(defence.text.split())
|
90
|
+
print(special_attack.text.split())
|
91
|
+
print(special_defence.text.split())
|
92
|
+
print(speed.text.split())
|
93
|
+
print(average.text.split())
|
94
|
+
|
95
|
+
実行すると
|
96
|
+
|
97
|
+
◆ チェリムの種族値
|
98
|
+
['HP', '70']
|
99
|
+
['こうげき', '60']
|
100
|
+
['ぼうぎょ', '70']
|
101
|
+
['とくこう', '87']
|
102
|
+
['とくぼう', '78']
|
103
|
+
['すばやさ', '85']
|
104
|
+
['平均', '/', '合計', '75.0', '/', '450']
|
105
|
+
フラワーギフト天気が『にほんばれ』の時、ポジフォルムにフォルムチェンジする。種族値などは変わらないが、自分とすべての味方の『こうげき』『とくぼう』が1.5倍になる。
|
106
|
+
|
107
|
+
と表示され
|
108
|
+
AttributeError Traceback (most recent call last)
|
109
|
+
<ipython-input-4-ed11b57b4eb5> in <module>
|
110
|
+
8 special_attack = defence.find_next_sibling()
|
111
|
+
9 special_defence = special_attack.find_next_sibling()
|
112
|
+
---> 10 speed = special_defence.find_next_sibling()
|
113
|
+
11 average = speed.find_next_sibling()
|
114
|
+
12
|
115
|
+
|
116
|
+
AttributeError: 'NoneType' object has no attribute 'find_next_sibling'
|
117
|
+
|
118
|
+
エラーになります。このページだけ他と違う理由がわからないです。
|