質問編集履歴
3
自分で改善した所を変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
flaskでデータフレームを表示
|
1
|
+
flaskでデータフレームをhtmlに表示する方法について
|
test
CHANGED
@@ -1,24 +1,20 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
初めての質問で仕方が失礼があればすいません。
|
4
|
-
|
5
3
|
flaskを使いスクレイピングしたデータフレームをhtmlで選択したデータを表示させたい。
|
6
4
|
|
5
|
+
|
6
|
+
|
7
|
+
手順
|
8
|
+
|
7
9
|
1.野球のデータをpandasを使ってスクレイピングする。
|
8
10
|
|
9
11
|
2.htmlで選択肢を配置。
|
10
12
|
|
11
|
-
3.pandasで作ったスクレイピング関数をflaskを使って選択した
|
13
|
+
3.pandasで作ったスクレイピング関数をflaskを使って選択したdataframだけ表示させる。
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
|
15
|
+
|
16
|
+
|
15
|
-
|
17
|
+
チームと年代を選択して決定を押してもエラーが出るので直したい。
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
4.表示させたデータからユーザーが選手を選択できるようにする。(テーブルから選択できるようにして、データをpythonが受け取る)
|
20
|
-
|
21
|
-
|
22
18
|
|
23
19
|
|
24
20
|
|
@@ -30,8 +26,6 @@
|
|
30
26
|
|
31
27
|
(base) hatea@hateanoMacBook-Pro baseball data % source /Users/hatea/opt/anaconda3/bin/activate
|
32
28
|
|
33
|
-
conda activate base
|
34
|
-
|
35
29
|
(base) hatea@hateanoMacBook-Pro baseball data % conda activate base
|
36
30
|
|
37
31
|
(base) hatea@hateanoMacBook-Pro baseball data % /Users/hatea/opt/anaconda3/bin/python "/Users/hatea/Desktop/baseball data/flask/app.py"
|
@@ -46,7 +40,7 @@
|
|
46
40
|
|
47
41
|
* Debug mode: on
|
48
42
|
|
49
|
-
* Running on http://
|
43
|
+
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
|
50
44
|
|
51
45
|
* Restarting with fsevents reloader
|
52
46
|
|
@@ -54,9 +48,11 @@
|
|
54
48
|
|
55
49
|
* Debugger PIN: 653-563-779
|
56
50
|
|
57
|
-
127.0.0.1 - - [
|
51
|
+
127.0.0.1 - - [22/Jun/2020 21:42:23] "GET / HTTP/1.1" 200 -
|
52
|
+
|
58
|
-
|
53
|
+
m
|
54
|
+
|
59
|
-
127.0.0.1 - - [
|
55
|
+
127.0.0.1 - - [22/Jun/2020 21:42:28] "POST / HTTP/1.1" 500 -
|
60
56
|
|
61
57
|
Traceback (most recent call last):
|
62
58
|
|
@@ -100,11 +96,11 @@
|
|
100
96
|
|
101
97
|
return self.view_functions[rule.endpoint](**req.view_args)
|
102
98
|
|
103
|
-
File "/Users/hatea/Desktop/baseball data/flask/app.py", line 1
|
99
|
+
File "/Users/hatea/Desktop/baseball data/flask/app.py", line 15, in index
|
104
|
-
|
100
|
+
|
105
|
-
players =
|
101
|
+
players = base_ball.data_load(year,team)
|
106
|
-
|
102
|
+
|
107
|
-
File "/Users/hatea/Desktop/baseball data/flask/base_ball.py", line 1
|
103
|
+
File "/Users/hatea/Desktop/baseball data/flask/base_ball.py", line 14, in data_load
|
108
104
|
|
109
105
|
dfs = pd.io.html.read_html(BASE_URL)
|
110
106
|
|
@@ -178,17 +174,15 @@
|
|
178
174
|
|
179
175
|
urllib.error.HTTPError: HTTP Error 404: Not Found
|
180
176
|
|
181
|
-
127.0.0.1 - - [
|
177
|
+
127.0.0.1 - - [22/Jun/2020 21:42:28] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
|
182
|
-
|
178
|
+
|
183
|
-
127.0.0.1 - - [
|
179
|
+
127.0.0.1 - - [22/Jun/2020 21:42:28] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
|
184
|
-
|
180
|
+
|
185
|
-
127.0.0.1 - - [
|
181
|
+
127.0.0.1 - - [22/Jun/2020 21:42:28] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
|
186
|
-
|
182
|
+
|
187
|
-
127.0.0.1 - - [
|
183
|
+
127.0.0.1 - - [22/Jun/2020 21:42:28] "GET /?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
|
188
|
-
|
184
|
+
|
189
|
-
127.0.0.1 - - [
|
185
|
+
127.0.0.1 - - [22/Jun/2020 21:42:28] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
|
190
|
-
|
191
|
-
|
192
186
|
|
193
187
|
```
|
194
188
|
|
@@ -200,6 +194,56 @@
|
|
200
194
|
|
201
195
|
```python
|
202
196
|
|
197
|
+
base_ball.py
|
198
|
+
|
199
|
+
from IPython import get_ipython
|
200
|
+
|
201
|
+
import random
|
202
|
+
|
203
|
+
import matplotlib.pyplot as plt
|
204
|
+
|
205
|
+
import numpy as np
|
206
|
+
|
207
|
+
import pandas as pd
|
208
|
+
|
209
|
+
import sys
|
210
|
+
|
211
|
+
#野手データ取得
|
212
|
+
|
213
|
+
def data_load(year,team):
|
214
|
+
|
215
|
+
BASE_URL = ("http://npb.jp/bis/{}/stats/idb1_{}.html".format(year,team))
|
216
|
+
|
217
|
+
dfs = pd.io.html.read_html(BASE_URL)
|
218
|
+
|
219
|
+
#カラムの再設定
|
220
|
+
|
221
|
+
df = dfs[0][1:]; df.columns=dfs[0].loc[0,:]
|
222
|
+
|
223
|
+
new_header = df.iloc[0]
|
224
|
+
|
225
|
+
df = df[1:]
|
226
|
+
|
227
|
+
df.columns = new_header
|
228
|
+
|
229
|
+
df2 = df.rename(columns=lambda s: str(s).replace(" ",""))
|
230
|
+
|
231
|
+
df_i = df2.rename(columns=lambda s: str(s).replace(" ",""))
|
232
|
+
|
233
|
+
del df_i['nan']
|
234
|
+
|
235
|
+
df3 = df_i.set_index('選手')
|
236
|
+
|
237
|
+
return df3
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
```
|
242
|
+
|
243
|
+
```python
|
244
|
+
|
245
|
+
app.py
|
246
|
+
|
203
247
|
import os
|
204
248
|
|
205
249
|
from flask import Flask, render_template,request
|
@@ -220,6 +264,8 @@
|
|
220
264
|
|
221
265
|
team = request.form.get('team','')
|
222
266
|
|
267
|
+
print(year,team)
|
268
|
+
|
223
269
|
if year == '2019' and team == 'bs':
|
224
270
|
|
225
271
|
players = base_ball.data_load(year,'b')
|
@@ -228,6 +274,14 @@
|
|
228
274
|
|
229
275
|
players = base_ball.data_load(year,team)
|
230
276
|
|
277
|
+
if int(year) >= 2011 and team == 'db':
|
278
|
+
|
279
|
+
players = base_ball.data_load(year,'yb')
|
280
|
+
|
281
|
+
else:
|
282
|
+
|
283
|
+
players = base_ball.data_load(year,team)
|
284
|
+
|
231
285
|
players = base_ball.data_load(year,team)
|
232
286
|
|
233
287
|
players_values = players.values.tolist()
|
@@ -250,12 +304,16 @@
|
|
250
304
|
|
251
305
|
if __name__ == '__main__':
|
252
306
|
|
253
|
-
app.run(debug=True, host='
|
307
|
+
app.run(debug=True, host='127.0.0.1',port=5000,threaded=True)
|
254
308
|
|
255
309
|
```
|
256
310
|
|
311
|
+
|
312
|
+
|
257
313
|
```html
|
258
314
|
|
315
|
+
index.html
|
316
|
+
|
259
317
|
<fieldset>
|
260
318
|
|
261
319
|
<legend>自チームを選ぼう</legend>
|
@@ -352,12 +410,6 @@
|
|
352
410
|
|
353
411
|
```
|
354
412
|
|
355
|
-
### 試したこと
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
データの受け取り方などを調べる。
|
360
|
-
|
361
413
|
|
362
414
|
|
363
415
|
### 補足情報(FW/ツールのバージョンなど)
|
2
else文の追加 htmlタグの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -200,188 +200,158 @@
|
|
200
200
|
|
201
201
|
```python
|
202
202
|
|
203
|
-
|
203
|
+
import os
|
204
|
+
|
204
|
-
|
205
|
+
from flask import Flask, render_template,request
|
206
|
+
|
205
|
-
import
|
207
|
+
import base_ball
|
208
|
+
|
206
|
-
|
209
|
+
app = Flask(__name__)
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
@app.route('/',methods=["GET","POST"])
|
214
|
+
|
207
|
-
|
215
|
+
def index():
|
216
|
+
|
208
|
-
|
217
|
+
if request.method == 'POST':
|
218
|
+
|
219
|
+
year = request.form.get('year','')
|
220
|
+
|
221
|
+
team = request.form.get('team','')
|
222
|
+
|
223
|
+
if year == '2019' and team == 'bs':
|
224
|
+
|
225
|
+
players = base_ball.data_load(year,'b')
|
226
|
+
|
227
|
+
else:
|
228
|
+
|
209
|
-
|
229
|
+
players = base_ball.data_load(year,team)
|
210
|
-
|
211
|
-
|
230
|
+
|
212
|
-
|
213
|
-
|
231
|
+
players = base_ball.data_load(year,team)
|
214
|
-
|
232
|
+
|
215
|
-
|
233
|
+
players_values = players.values.tolist()
|
216
|
-
|
234
|
+
|
217
|
-
|
235
|
+
players_columns = players.columns.tolist()
|
236
|
+
|
218
|
-
|
237
|
+
players_index = players.index.tolist()
|
238
|
+
|
239
|
+
return render_template('index.html', \
|
240
|
+
|
219
|
-
|
241
|
+
players_values = players_values, \
|
220
|
-
|
221
|
-
|
242
|
+
|
222
|
-
|
223
|
-
|
243
|
+
players_columns = players_columns, \
|
224
|
-
|
244
|
+
|
225
|
-
|
245
|
+
players_index = players_index)
|
246
|
+
|
247
|
+
return render_template('index.html')
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
if __name__ == '__main__':
|
252
|
+
|
253
|
+
app.run(debug=True, host='0.0.0.0',threaded=True)
|
226
254
|
|
227
255
|
```
|
228
256
|
|
229
|
-
```
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
fr
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
i
|
282
|
-
|
283
|
-
|
257
|
+
```html
|
258
|
+
|
259
|
+
<fieldset>
|
260
|
+
|
261
|
+
<legend>自チームを選ぼう</legend>
|
262
|
+
|
263
|
+
<form method="post" action="/">
|
264
|
+
|
265
|
+
<label for="year">年代を選択</label>
|
266
|
+
|
267
|
+
<select id="year">
|
268
|
+
|
269
|
+
<option name="year" value="2005">2005年</option>
|
270
|
+
|
271
|
+
<option name="year" value="2006">2006年</option>
|
272
|
+
|
273
|
+
<option name="year" value="2007">2007年</option>
|
274
|
+
|
275
|
+
<option name="year" value="2008">2008年</option>
|
276
|
+
|
277
|
+
<option name="year" value="2009">2009年</option>
|
278
|
+
|
279
|
+
<option name="year" value="2010">2010年</option>
|
280
|
+
|
281
|
+
<option name="year" value="2011">2011年</option>
|
282
|
+
|
283
|
+
<option name="year" value="2012">2012年</option>
|
284
|
+
|
285
|
+
<option name="year" value="2013">2013年</option>
|
286
|
+
|
287
|
+
<option name="year" value="2014">2014年</option>
|
288
|
+
|
289
|
+
<option name="year" value="2015">2015年</option>
|
290
|
+
|
291
|
+
<option name="year" value="2016">2016年</option>
|
292
|
+
|
293
|
+
<option name="year" value="2017">2017年</option>
|
294
|
+
|
295
|
+
<option name="year" value="2018">2018年</option>
|
296
|
+
|
297
|
+
<option selected name="year" value="2019">2019年</option>
|
298
|
+
|
299
|
+
</select>
|
300
|
+
|
301
|
+
<label><input type="radio" name="team" value="h">ソフトバンク</label>
|
302
|
+
|
303
|
+
<label><input type="radio" name="team" value="l">西武</label>
|
304
|
+
|
305
|
+
<label><input type="radio" name="team" value="e">楽天</label>
|
306
|
+
|
307
|
+
<label><input type="radio" name="team" value="m">ロッテ</label>
|
308
|
+
|
309
|
+
<label><input type="radio" name="team" value="f">日本ハム</label>
|
310
|
+
|
311
|
+
<label><input type="radio" name="team" value="bs">オリックス</label>
|
312
|
+
|
313
|
+
<label><input type="radio" name="team" value="c">広島</label>
|
314
|
+
|
315
|
+
<label><input type="radio" name="team" value="db">横浜</label>
|
316
|
+
|
317
|
+
<label><input type="radio" name="team" value="g">巨人</label>
|
318
|
+
|
319
|
+
<label><input type="radio" name="team" value="t">阪神</label>
|
320
|
+
|
321
|
+
<label><input type="radio" name="team" value="s">ヤクルト</label>
|
322
|
+
|
323
|
+
<label><input type="radio" name="team" value="d">中日</label>
|
324
|
+
|
325
|
+
</fieldset>
|
326
|
+
|
327
|
+
<div><input type="submit" value="決定"></div>
|
328
|
+
|
329
|
+
</form>
|
330
|
+
|
331
|
+
<table>
|
332
|
+
|
333
|
+
<thead>
|
334
|
+
|
335
|
+
<tr>{%- for i in players_columns %}<th>{{ i|e }}</th>{%- endfor %}</tr>
|
336
|
+
|
337
|
+
</thead>
|
338
|
+
|
339
|
+
<tbody>
|
340
|
+
|
341
|
+
{%- for i in players_values %}
|
342
|
+
|
343
|
+
<tr><th>{{ players_index[loop.index0]|e }}</th>{% for j in i %}<td>{{ j|e }}</td>{% endfor %}</tr>
|
344
|
+
|
345
|
+
{%- endfor %}
|
346
|
+
|
347
|
+
</tbody>
|
348
|
+
|
349
|
+
</table>
|
350
|
+
|
351
|
+
<fieldset>
|
284
352
|
|
285
353
|
```
|
286
354
|
|
287
|
-
```html
|
288
|
-
|
289
|
-
<fieldset>
|
290
|
-
|
291
|
-
<legend>自チームを選ぼう</legend>
|
292
|
-
|
293
|
-
<form method="post" action="/">
|
294
|
-
|
295
|
-
<label for="year">年代を選択</label>
|
296
|
-
|
297
|
-
<select id="year">
|
298
|
-
|
299
|
-
<option name="year" value="2005">2005年</option>
|
300
|
-
|
301
|
-
<option name="year" value="2006">2006年</option>
|
302
|
-
|
303
|
-
<option name="year" value="2007">2007年</option>
|
304
|
-
|
305
|
-
<option name="year" value="2008">2008年</option>
|
306
|
-
|
307
|
-
<option name="year" value="2009">2009年</option>
|
308
|
-
|
309
|
-
<option name="year" value="2010">2010年</option>
|
310
|
-
|
311
|
-
<option name="year" value="2011">2011年</option>
|
312
|
-
|
313
|
-
<option name="year" value="2012">2012年</option>
|
314
|
-
|
315
|
-
<option name="year" value="2013">2013年</option>
|
316
|
-
|
317
|
-
<option name="year" value="2014">2014年</option>
|
318
|
-
|
319
|
-
<option name="year" value="2015">2015年</option>
|
320
|
-
|
321
|
-
<option name="year" value="2016">2016年</option>
|
322
|
-
|
323
|
-
<option name="year" value="2017">2017年</option>
|
324
|
-
|
325
|
-
<option name="year" value="2018">2018年</option>
|
326
|
-
|
327
|
-
<option selected name="year" value="2019">2019年</option>
|
328
|
-
|
329
|
-
</select>
|
330
|
-
|
331
|
-
<label><input type="radio" name="team" value="h">ソフトバンク</label>
|
332
|
-
|
333
|
-
<label><input type="radio" name="team" value="l">西武</label>
|
334
|
-
|
335
|
-
<label><input type="radio" name="team" value="e">楽天</label>
|
336
|
-
|
337
|
-
<label><input type="radio" name="team" value="m">ロッテ</label>
|
338
|
-
|
339
|
-
<label><input type="radio" name="team" value="f">日本ハム</label>
|
340
|
-
|
341
|
-
<label><input type="radio" name="team" value="bs">オリックス</label>
|
342
|
-
|
343
|
-
<label><input type="radio" name="team" value="c">広島</label>
|
344
|
-
|
345
|
-
<label><input type="radio" name="team" value="db">横浜</label>
|
346
|
-
|
347
|
-
<label><input type="radio" name="team" value="g">巨人</label>
|
348
|
-
|
349
|
-
<label><input type="radio" name="team" value="t">阪神</label>
|
350
|
-
|
351
|
-
<label><input type="radio" name="team" value="s">ヤクルト</label>
|
352
|
-
|
353
|
-
<label><input type="radio" name="team" value="d">中日</label>
|
354
|
-
|
355
|
-
</fieldset>
|
356
|
-
|
357
|
-
<div><input type="submit" value="決定"></div>
|
358
|
-
|
359
|
-
</form>
|
360
|
-
|
361
|
-
<table>
|
362
|
-
|
363
|
-
<thead>
|
364
|
-
|
365
|
-
<tr>{%- for i in players_columns %}<th>{{ i|e }}</th>{%- endfor %}</tr>
|
366
|
-
|
367
|
-
</thead>
|
368
|
-
|
369
|
-
<tbody>
|
370
|
-
|
371
|
-
{%- for i in players_values %}
|
372
|
-
|
373
|
-
<tr><th>{{ players_index[loop.index0]|e }}</th>{% for j in i %}<td>{{ j|e }}</td>{% endfor %}</tr>
|
374
|
-
|
375
|
-
{%- endfor %}
|
376
|
-
|
377
|
-
</tbody>
|
378
|
-
|
379
|
-
</table>
|
380
|
-
|
381
|
-
<fieldset>
|
382
|
-
|
383
|
-
```
|
384
|
-
|
385
355
|
### 試したこと
|
386
356
|
|
387
357
|
|
1
エラー文の全文、追加条件分岐
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,10 +28,168 @@
|
|
28
28
|
|
29
29
|
```
|
30
30
|
|
31
|
+
(base) hatea@hateanoMacBook-Pro baseball data % source /Users/hatea/opt/anaconda3/bin/activate
|
32
|
+
|
33
|
+
conda activate base
|
34
|
+
|
35
|
+
(base) hatea@hateanoMacBook-Pro baseball data % conda activate base
|
36
|
+
|
37
|
+
(base) hatea@hateanoMacBook-Pro baseball data % /Users/hatea/opt/anaconda3/bin/python "/Users/hatea/Desktop/baseball data/flask/app.py"
|
38
|
+
|
39
|
+
* Serving Flask app "app" (lazy loading)
|
40
|
+
|
41
|
+
* Environment: production
|
42
|
+
|
43
|
+
WARNING: This is a development server. Do not use it in a production deployment.
|
44
|
+
|
45
|
+
Use a production WSGI server instead.
|
46
|
+
|
47
|
+
* Debug mode: on
|
48
|
+
|
49
|
+
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
|
50
|
+
|
51
|
+
* Restarting with fsevents reloader
|
52
|
+
|
53
|
+
* Debugger is active!
|
54
|
+
|
55
|
+
* Debugger PIN: 653-563-779
|
56
|
+
|
57
|
+
127.0.0.1 - - [15/Jun/2020 11:49:25] "GET / HTTP/1.1" 200 -
|
58
|
+
|
59
|
+
127.0.0.1 - - [15/Jun/2020 11:49:33] "POST / HTTP/1.1" 500 -
|
60
|
+
|
61
|
+
Traceback (most recent call last):
|
62
|
+
|
63
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
|
64
|
+
|
65
|
+
return self.wsgi_app(environ, start_response)
|
66
|
+
|
67
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
|
68
|
+
|
69
|
+
response = self.handle_exception(e)
|
70
|
+
|
71
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
|
72
|
+
|
73
|
+
reraise(exc_type, exc_value, tb)
|
74
|
+
|
75
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
|
76
|
+
|
77
|
+
raise value
|
78
|
+
|
79
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
|
80
|
+
|
81
|
+
response = self.full_dispatch_request()
|
82
|
+
|
83
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
|
84
|
+
|
85
|
+
rv = self.handle_user_exception(e)
|
86
|
+
|
87
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
|
88
|
+
|
89
|
+
reraise(exc_type, exc_value, tb)
|
90
|
+
|
91
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
|
92
|
+
|
93
|
+
raise value
|
94
|
+
|
95
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
|
96
|
+
|
97
|
+
rv = self.dispatch_request()
|
98
|
+
|
99
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
|
100
|
+
|
101
|
+
return self.view_functions[rule.endpoint](**req.view_args)
|
102
|
+
|
103
|
+
File "/Users/hatea/Desktop/baseball data/flask/app.py", line 11, in index
|
104
|
+
|
105
|
+
players = base_ball.data_load(year,team)
|
106
|
+
|
107
|
+
File "/Users/hatea/Desktop/baseball data/flask/base_ball.py", line 13, in data_load
|
108
|
+
|
109
|
+
dfs = pd.io.html.read_html(BASE_URL)
|
110
|
+
|
111
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/pandas/io/html.py", line 1100, in read_html
|
112
|
+
|
113
|
+
displayed_only=displayed_only,
|
114
|
+
|
115
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/pandas/io/html.py", line 895, in _parse
|
116
|
+
|
117
|
+
tables = p.parse_tables()
|
118
|
+
|
119
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/pandas/io/html.py", line 213, in parse_tables
|
120
|
+
|
121
|
+
tables = self._parse_tables(self._build_doc(), self.match, self.attrs)
|
122
|
+
|
123
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/pandas/io/html.py", line 733, in _build_doc
|
124
|
+
|
125
|
+
raise e
|
126
|
+
|
127
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/pandas/io/html.py", line 714, in _build_doc
|
128
|
+
|
129
|
+
with urlopen(self.io) as f:
|
130
|
+
|
131
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/site-packages/pandas/io/common.py", line 141, in urlopen
|
132
|
+
|
133
|
+
return urllib.request.urlopen(*args, **kwargs)
|
134
|
+
|
135
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 222, in urlopen
|
136
|
+
|
137
|
+
return opener.open(url, data, timeout)
|
138
|
+
|
139
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 531, in open
|
140
|
+
|
141
|
+
response = meth(req, response)
|
142
|
+
|
143
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 641, in http_response
|
144
|
+
|
145
|
+
'http', request, response, code, msg, hdrs)
|
146
|
+
|
147
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 563, in error
|
148
|
+
|
149
|
+
result = self._call_chain(*args)
|
150
|
+
|
151
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 503, in _call_chain
|
152
|
+
|
153
|
+
result = func(*args)
|
154
|
+
|
155
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 755, in http_error_302
|
156
|
+
|
157
|
+
return self.parent.open(new, timeout=req.timeout)
|
158
|
+
|
159
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 531, in open
|
160
|
+
|
161
|
+
response = meth(req, response)
|
162
|
+
|
163
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 641, in http_response
|
164
|
+
|
165
|
+
'http', request, response, code, msg, hdrs)
|
166
|
+
|
167
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 569, in error
|
168
|
+
|
169
|
+
return self._call_chain(*args)
|
170
|
+
|
171
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 503, in _call_chain
|
172
|
+
|
173
|
+
result = func(*args)
|
174
|
+
|
175
|
+
File "/Users/hatea/opt/anaconda3/lib/python3.7/urllib/request.py", line 649, in http_error_default
|
176
|
+
|
31
|
-
raise HTTPError(req.full_url, code, msg, hdrs, fp)
|
177
|
+
raise HTTPError(req.full_url, code, msg, hdrs, fp)
|
32
178
|
|
33
179
|
urllib.error.HTTPError: HTTP Error 404: Not Found
|
34
180
|
|
181
|
+
127.0.0.1 - - [15/Jun/2020 11:49:33] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 -
|
182
|
+
|
183
|
+
127.0.0.1 - - [15/Jun/2020 11:49:33] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 -
|
184
|
+
|
185
|
+
127.0.0.1 - - [15/Jun/2020 11:49:33] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 -
|
186
|
+
|
187
|
+
127.0.0.1 - - [15/Jun/2020 11:49:33] "GET /?__debugger__=yes&cmd=resource&f=ubuntu.ttf HTTP/1.1" 200 -
|
188
|
+
|
189
|
+
127.0.0.1 - - [15/Jun/2020 11:49:33] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 -
|
190
|
+
|
191
|
+
|
192
|
+
|
35
193
|
```
|
36
194
|
|
37
195
|
|
@@ -92,6 +250,14 @@
|
|
92
250
|
|
93
251
|
team = request.form.get('team','')
|
94
252
|
|
253
|
+
#追加------------------------------------------------------------
|
254
|
+
|
255
|
+
if year == '2019' and team =='bs':
|
256
|
+
|
257
|
+
players = base_ball.data_load(year,'b')
|
258
|
+
|
259
|
+
#----------------------------------------------------------------
|
260
|
+
|
95
261
|
players = base_ball.data_load(year,team)
|
96
262
|
|
97
263
|
players_values = players.values.tolist()
|