質問編集履歴
3
補足情報にページソースの一部を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,6 +82,424 @@
|
|
82
82
|
|
83
83
|
### 補足情報(FW/ツールのバージョンなど)
|
84
84
|
|
85
|
-
|
86
|
-
|
87
85
|
python3.7 windows10
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
スクレイピングするサイトのソース一部抜粋
|
90
|
+
|
91
|
+
```HTML
|
92
|
+
|
93
|
+
<!DOCTYPE html>
|
94
|
+
|
95
|
+
<html>
|
96
|
+
|
97
|
+
<head>
|
98
|
+
|
99
|
+
<meta charset="EUC-JP">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
_______________________________________________________________
|
104
|
+
|
105
|
+
<tr class="HorseList" id="tr_9">
|
106
|
+
|
107
|
+
<td class="Waku1 Txt_C"><span>1</span></td>
|
108
|
+
|
109
|
+
<td class="Umaban1 Txt_C">1</td>
|
110
|
+
|
111
|
+
<td class="CheckMark Horse_Select">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
<select class="makeMeFancy_9" name="9" id="mark_9" style="display: none;">
|
116
|
+
|
117
|
+
<option data-html-text="--" value="1_0">--</option><option data-html-text="◎" value="1_1">◎</option><option data-html-text="◯" value="1_2">◯</option><option data-html-text="▲" value="1_3">▲</option><option data-html-text="△" value="1_4">△</option><option data-html-text="☆" value="1_5">☆</option><option data-html-text="&#10003" value="1_98">&#10003</option><option data-html-text="消" value="1_99">消</option>
|
118
|
+
|
119
|
+
</select>
|
120
|
+
|
121
|
+
</td>
|
122
|
+
|
123
|
+
<td class="HorseInfo">
|
124
|
+
|
125
|
+
<div>
|
126
|
+
|
127
|
+
<div>
|
128
|
+
|
129
|
+
<span class="HorseName"><a href="https://db.netkeiba.com/horse/2017104753" target="_blank" title="サトノインプレッサ">サトノインプレッサ<img id="myhorse_2017104753" class="disp_none Favorite" src="https://cdn.netkeiba.com/img.racev3/common/img/icon/icon_horse.png?2019073001" alt="" width="18"></a></span>
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
</div>
|
134
|
+
|
135
|
+
</td>
|
136
|
+
|
137
|
+
<td class="Barei">牡3</td>
|
138
|
+
|
139
|
+
<td class="Txt_C">57.0</td>
|
140
|
+
|
141
|
+
<td class="Jockey">
|
142
|
+
|
143
|
+
<a href="https://db.netkeiba.com/jockey/01163/" target="_blank" title="坂井">坂井</a>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
</td>
|
150
|
+
|
151
|
+
<td class="Trainer"><span class="Label2">栗東</span><a href="https://db.netkeiba.com/trainer/01075/" target="_blank" title="矢作">矢作</a></td>
|
152
|
+
|
153
|
+
<td class="Weight">
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
</td>
|
158
|
+
|
159
|
+
<td class="Txt_R Popular"><span id="odds-1_01" style="font-weight : bold">---.-</span></td>
|
160
|
+
|
161
|
+
<td class="Popular Popular_Ninki Txt_C">
|
162
|
+
|
163
|
+
<span id="ninki-1_01">**</span>
|
164
|
+
|
165
|
+
</td>
|
166
|
+
|
167
|
+
<td class="FavRegist Txt_C">
|
168
|
+
|
169
|
+
<a href="../popup/horse_bookmark.html?ketto_num=2017104753&race_id=202005021211" title="お気に入り馬登録" class="popup_link_04 cboxElement cboxElement_Nologin">
|
170
|
+
|
171
|
+
<img src="https://cdn.netkeiba.com/img.racev3/common/img/icon/prof_icon_favhorse_comp_01.png?2019073001" class="horsebookmark myhorse1_2017104753" onmouseover="this.src='https://cdn.netkeiba.com/img.racev3/common/img/icon/prof_icon_favhorse_comp_01.png?2019073001'" onmouseout="this.src='https://cdn.netkeiba.com/img.racev3/common/img/icon/prof_icon_favhorse_comp_01.png?2019073001'">
|
172
|
+
|
173
|
+
<img id="myhorse1_2017104753" src="https://cdn.netkeiba.com/img.racev3/common/img/icon/prof_icon_favhorse_comp_02.png?2019073001" class="disp_none horsebookmark myhorse_2017104753" onmouseover="this.src='https://cdn.netkeiba.com/img.racev3/common/img/icon/prof_icon_favhorse_comp_02.png?2019073001'" onmouseout="this.src='https://cdn.netkeiba.com/img.racev3/common/img/icon/prof_icon_favhorse_comp_02.png?2019073001'">
|
174
|
+
|
175
|
+
</a> </td>
|
176
|
+
|
177
|
+
<td class="FavMemo"><div><a href="../popup/horse_bookmark.html?ketto_num=2017104753&race_id=202005021211" id="Bamei_2017104753" title="" class="popup_link_04 cboxElement"></a></div></td>
|
178
|
+
|
179
|
+
</tr>
|
180
|
+
|
181
|
+
_________________________________________________________________
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
<div style="display:none;" id="free_odds_limit_overlay"></div>
|
186
|
+
|
187
|
+
<script type="text/javascript">
|
188
|
+
|
189
|
+
$(function(){
|
190
|
+
|
191
|
+
//tablesorterの不具合のため、馬番がNULLの場合に馬名のソートの振る舞いを変更する
|
192
|
+
|
193
|
+
$("tbody .HorseInfo").each( function() {
|
194
|
+
|
195
|
+
var rowIndex = $(this).parent().index();
|
196
|
+
|
197
|
+
if ($("tbody [class^=Umaban]").eq(rowIndex).text() == "") {
|
198
|
+
|
199
|
+
$(this).attr("data-sort-value", rowIndex+1);
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
});
|
204
|
+
|
205
|
+
// オッズ更新click
|
206
|
+
|
207
|
+
$(".OddsUpdataBtn").on({"click":
|
208
|
+
|
209
|
+
function(){
|
210
|
+
|
211
|
+
$(".OddsUpdataBtn").removeClass("OddsUpdataClick");
|
212
|
+
|
213
|
+
$(".OddsUpdataBtn").addClass("OddsUpdataClick");
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
});
|
218
|
+
|
219
|
+
});
|
220
|
+
|
221
|
+
</script>
|
222
|
+
|
223
|
+
<script>
|
224
|
+
|
225
|
+
"use strict"
|
226
|
+
|
227
|
+
$(function(){
|
228
|
+
|
229
|
+
/* Area created in the intern Start */
|
230
|
+
|
231
|
+
const nullCheak = function(date){ return !date[0] ? true : false };
|
232
|
+
|
233
|
+
var firstTime = true;
|
234
|
+
|
235
|
+
const table_sorte = function(t_header_flg){
|
236
|
+
|
237
|
+
$('.Shutuba_Table th').unbind();
|
238
|
+
|
239
|
+
$.tablesorter.destroy( $('.Shutuba_Table'), true, function(table) {});
|
240
|
+
|
241
|
+
$('.Shutuba_Table').tablesorter({
|
242
|
+
|
243
|
+
headers: {
|
244
|
+
|
245
|
+
0: { sorter: "false" },
|
246
|
+
|
247
|
+
1: { sorter: t_header_flg[1] },
|
248
|
+
|
249
|
+
2: { sorter: "false" },
|
250
|
+
|
251
|
+
3: { sorter: "text" },
|
252
|
+
|
253
|
+
4: { sorter: "false" },
|
254
|
+
|
255
|
+
5: { sorter: t_header_flg[5] },
|
256
|
+
|
257
|
+
6: { sorter: "false" },
|
258
|
+
|
259
|
+
7: { sorter: "false" },
|
260
|
+
|
261
|
+
8: { sorter: t_header_flg[8] },
|
262
|
+
|
263
|
+
9: { sorter: "false" },
|
264
|
+
|
265
|
+
10: { sorter: t_header_flg[10] },
|
266
|
+
|
267
|
+
11: { sorter: "false" },
|
268
|
+
|
269
|
+
12: { sorter: "false" },
|
270
|
+
|
271
|
+
13: { sorter: "false" },
|
272
|
+
|
273
|
+
},
|
274
|
+
|
275
|
+
//tablesorterの不具合のため、馬番がNULLの場合に馬名のソートの振る舞いを変更する
|
276
|
+
|
277
|
+
textExtraction: function(node) {
|
278
|
+
|
279
|
+
var attr = $(node).attr('data-sort-value');
|
280
|
+
|
281
|
+
if (typeof attr !== 'undefined' && attr !== false) {
|
282
|
+
|
283
|
+
return attr;
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
return $(node).text();
|
288
|
+
|
289
|
+
}
|
290
|
+
|
291
|
+
});
|
292
|
+
|
293
|
+
};
|
294
|
+
|
295
|
+
// $(window).load(function(){
|
296
|
+
|
297
|
+
var tableSorteAction = function() {
|
298
|
+
|
299
|
+
const Umaban = $('td.Umaban');
|
300
|
+
|
301
|
+
const weight = $('td.Weight small');
|
302
|
+
|
303
|
+
const t_header_icons = $('.sort_icon');
|
304
|
+
|
305
|
+
// sort flag [0:枠,1:印,2:名,3:オッズ,4:体重]
|
306
|
+
|
307
|
+
var t_sorts_flg = [true,true,true,true,true,true,true,true, true, true, true, false ];
|
308
|
+
|
309
|
+
// sort Icon generation
|
310
|
+
|
311
|
+
const icon = $('<i></i>',{
|
312
|
+
|
313
|
+
'class' : 'fas fa-sort',
|
314
|
+
|
315
|
+
});
|
316
|
+
|
317
|
+
t_header_icons.append(icon);
|
318
|
+
|
319
|
+
// Empty check in frame order
|
320
|
+
|
321
|
+
if($('td').hasClass('Umaban')){
|
322
|
+
|
323
|
+
t_header_icons[0].remove();
|
324
|
+
|
325
|
+
t_sorts_flg[1] = false;
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
// Empty check of horse weight
|
330
|
+
|
331
|
+
if(!weight.length){
|
332
|
+
|
333
|
+
t_header_icons[3].remove();
|
334
|
+
|
335
|
+
// t_sorts_flg[3] = false;
|
336
|
+
|
337
|
+
t_sorts_flg[8] = false;
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
table_sorte(t_sorts_flg);
|
342
|
+
|
343
|
+
$('.sort_icon').css("display", "block");
|
344
|
+
|
345
|
+
$('.sort_icon').show();
|
346
|
+
|
347
|
+
};
|
348
|
+
|
349
|
+
/* Area created in the intern End */
|
350
|
+
|
351
|
+
$.oddsUpdate({
|
352
|
+
|
353
|
+
apiUrl:'https://race.netkeiba.com/api/api_get_jra_odds.html',
|
354
|
+
|
355
|
+
raceId:'202005021211',
|
356
|
+
|
357
|
+
isPremium:0,
|
358
|
+
|
359
|
+
displayDiffTime:false,
|
360
|
+
|
361
|
+
PremiumLinkReturnUrl : 'http%3A%2F%2Frace.netkeiba.com%2Frace%2Fshutuba.html%3Frace_id%3D202005021211',
|
362
|
+
|
363
|
+
PremiumLinkReturnRf : 'shutuba',
|
364
|
+
|
365
|
+
isBrackets : false,
|
366
|
+
|
367
|
+
compress:true,
|
368
|
+
|
369
|
+
callbackApiComplete:function(_this,_odds_status,_data){
|
370
|
+
|
371
|
+
// オッズ見出し
|
372
|
+
|
373
|
+
if(_odds_status=='yoso'){
|
374
|
+
|
375
|
+
$('#odds_title').html('予想<br />オッズ');
|
376
|
+
|
377
|
+
} else if(_odds_status=='result'){
|
378
|
+
|
379
|
+
$('#odds_title').html('オッズ');
|
380
|
+
|
381
|
+
} else if(_odds_status=='middle') {
|
382
|
+
|
383
|
+
$('#premium_guide').show();
|
384
|
+
|
385
|
+
$('#odds_title').html('オッズ');
|
386
|
+
|
387
|
+
} else {
|
388
|
+
|
389
|
+
$('#odds_title').html('オッズ');
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
// マイオッズ遷移先
|
394
|
+
|
395
|
+
var action = 'https://race.netkeiba.com';
|
396
|
+
|
397
|
+
var action_form_pid = '../odds/myodds';
|
398
|
+
|
399
|
+
if(_odds_status=='yoso'){
|
400
|
+
|
401
|
+
action = '';
|
402
|
+
|
403
|
+
action_form_pid = '../odds/index';
|
404
|
+
|
405
|
+
}
|
406
|
+
|
407
|
+
$('#shutuba_form').attr('action',action_form_pid+".html");
|
408
|
+
|
409
|
+
// オッズ着色
|
410
|
+
|
411
|
+
$('[id^="odds-1_"]').each(function(){
|
412
|
+
|
413
|
+
var data_key = $(this).prop('id').replace('odds-','').split('_');
|
414
|
+
|
415
|
+
var type = data_key[0];
|
416
|
+
|
417
|
+
var no = data_key[1];
|
418
|
+
|
419
|
+
if (_data) {
|
420
|
+
|
421
|
+
if(!$.isEmptyObject(_data['odds'][type])){
|
422
|
+
|
423
|
+
var ary_row = _data['odds'][type];
|
424
|
+
|
425
|
+
var row = ary_row[no];
|
426
|
+
|
427
|
+
if (row) {
|
428
|
+
|
429
|
+
$(this).text(row[0]);
|
430
|
+
|
431
|
+
if(type==1){
|
432
|
+
|
433
|
+
$(this).parent().parent().find(".Popular_Ninki")
|
434
|
+
|
435
|
+
.removeClass("BgYellow")
|
436
|
+
|
437
|
+
.removeClass("BgBlue02")
|
438
|
+
|
439
|
+
.removeClass("BgOrange");
|
440
|
+
|
441
|
+
if (row[2] == 1) {
|
442
|
+
|
443
|
+
$(this).parent().parent().find(".Popular_Ninki").addClass("BgYellow")
|
444
|
+
|
445
|
+
} else if (row[2] ==2) {
|
446
|
+
|
447
|
+
$(this).parent().parent().find(".Popular_Ninki").addClass("BgBlue02")
|
448
|
+
|
449
|
+
} else if (row[2] ==3) {
|
450
|
+
|
451
|
+
$(this).parent().parent().find(".Popular_Ninki").addClass("BgOrange")
|
452
|
+
|
453
|
+
}
|
454
|
+
|
455
|
+
}
|
456
|
+
|
457
|
+
}
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
}
|
462
|
+
|
463
|
+
$(this).parent().removeClass('Odds_Ninki');
|
464
|
+
|
465
|
+
$(this).removeClass('Odds_Ninki');
|
466
|
+
|
467
|
+
if($(this).text()<10){
|
468
|
+
|
469
|
+
$(this).parent().removeClass('Odds_Ninki');
|
470
|
+
|
471
|
+
$(this).addClass('Odds_Ninki');
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
});
|
476
|
+
|
477
|
+
var tmDeleteUpdateOddsClass = setTimeout(function(){
|
478
|
+
|
479
|
+
clearTimeout(tmDeleteUpdateOddsClass);
|
480
|
+
|
481
|
+
$(".Shutuba_Table tr .UpdateOdds").removeClass("UpdateOdds");
|
482
|
+
|
483
|
+
}, 700);
|
484
|
+
|
485
|
+
if (firstTime) {
|
486
|
+
|
487
|
+
firstTime = false;
|
488
|
+
|
489
|
+
tableSorteAction();
|
490
|
+
|
491
|
+
} else {
|
492
|
+
|
493
|
+
$(".Shutuba_Table").trigger('update', [true])
|
494
|
+
|
495
|
+
}
|
496
|
+
|
497
|
+
},
|
498
|
+
|
499
|
+
});
|
500
|
+
|
501
|
+
});
|
502
|
+
|
503
|
+
</script>
|
504
|
+
|
505
|
+
```
|
2
ページソースの一部 を編集しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
|
11
11
|
ページソースの一部______________________________
|
12
12
|
|
13
|
+
```HTML
|
14
|
+
|
13
15
|
<td class="Barei">牡3</td> #馬齢
|
14
16
|
|
15
17
|
<td class="Txt_C">57.0</td> #斤量
|
@@ -21,6 +23,8 @@
|
|
21
23
|
<span id="ninki-1_03">**</span> #人気
|
22
24
|
|
23
25
|
</td>
|
26
|
+
|
27
|
+
```
|
24
28
|
|
25
29
|
________________________________________
|
26
30
|
|
1
ソースコードのインデントの修正をしました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
コード
|
4
|
+
|
1
|
-
### 前提・実現したいこと
|
5
|
+
```### 前提・実現したいこと
|
2
6
|
|
3
7
|
netkeibaの出馬表ページから単勝オッズと人気をスクレイピングしたい
|
4
8
|
|
@@ -32,6 +36,8 @@
|
|
32
36
|
|
33
37
|
### 該当のソースコード(一部)#タグとclassを頼りにtextを引き抜いています
|
34
38
|
|
39
|
+
```python
|
40
|
+
|
35
41
|
soup = BeautifulSoup(r_text,"html.parser")
|
36
42
|
|
37
43
|
HorseLists = soup.find_all("tr",class_="HorseList")
|
@@ -64,6 +70,8 @@
|
|
64
70
|
|
65
71
|
odds.append(X.strip())
|
66
72
|
|
73
|
+
```
|
74
|
+
|
67
75
|
### 試したこと
|
68
76
|
|
69
77
|
このページソースの単勝オッズと人気の値はおそらく別のサイト?かどこかから値を引っ張て来ているのだろうとは思うのですが、HTMLに関する知識が乏しく、ページソース全体を見渡してみてもどういった構造になっているのかが理解できていない状況です
|