回答編集履歴
2
コードの修正
answer
CHANGED
@@ -22,6 +22,9 @@
|
|
22
22
|
for row in soup.select("#contents950 > div.twoColEq_L > table > tr.bg-1-pl"):
|
23
23
|
# 各行の3列目を取得する
|
24
24
|
col = row.select_one("td:nth-of-type(3)")
|
25
|
+
|
26
|
+
# または以下のコードでもOK
|
27
|
+
# col = row.find_all("td")[2]
|
25
28
|
|
26
29
|
# 空白や改行をトリミングする
|
27
30
|
print(col.text.strip())
|
1
書式の改善
answer
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
url = "https://www.nankankeiba.com/odds_nin/202003022114010204.do#odds"
|
13
13
|
r = requests.get(url)
|
14
14
|
|
15
|
-
# 文字化けするので
|
15
|
+
# 文字化けするのでエンコードをShift-JISに設定する
|
16
16
|
r.encoding = r.apparent_encoding
|
17
17
|
# r.encoding = 'Shift_JIS'
|
18
18
|
|