回答編集履歴
1
encoding="utf_8_sig"を忘れてました
answer
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
table class="data-table5"のtrを一行ずつ抽出、thかtdのテキストを抽出
|
2
2
|
|
3
|
-
|
4
3
|
```python
|
5
4
|
import csv
|
6
5
|
import requests
|
@@ -17,8 +16,7 @@
|
|
17
16
|
for tr in soup.select_one("table.data-table5").select("tr")
|
18
17
|
]
|
19
18
|
|
20
|
-
with open("result.csv", "w") as fw:
|
19
|
+
with open("result.csv", "w", encoding="utf_8_sig") as fw:
|
21
20
|
writer = csv.writer(fw, dialect="excel", lineterminator="\n")
|
22
|
-
|
23
21
|
writer.writerows(result)
|
24
22
|
```
|