質問編集履歴
1
ファイルへ書き出す処理を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,9 +18,10 @@
|
|
18
18
|
topics = soup.find(id = "Topics")
|
19
19
|
|
20
20
|
# aタグとhref属性取得
|
21
|
+
with open("info.txt", "w") as w:
|
21
|
-
for elem in topics.find_all("a"):
|
22
|
+
for elem in topics.find_all("a"):
|
22
|
-
data = elem.text + "," + elem.get("href")
|
23
|
+
data = elem.text + "," + elem.get("href")
|
23
|
-
|
24
|
+
w.write(data + "\n")
|
24
25
|
|
25
26
|
```
|
26
27
|
|