質問編集履歴
1
コードのインデントを整えました
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,14 +22,6 @@
|
|
22
22
|
|
23
23
|
```python
|
24
24
|
|
25
|
-
import requests
|
26
|
-
|
27
|
-
import re
|
28
|
-
|
29
|
-
from bs4 import BeautifulSoup
|
30
|
-
|
31
|
-
import datetime as dt
|
32
|
-
|
33
25
|
url = "https://www.eigonews.net/blog/"
|
34
26
|
|
35
27
|
headers = {"User-Agent": "hoge"}
|
@@ -50,25 +42,27 @@
|
|
50
42
|
|
51
43
|
for article in soup.find_all(class_="media-body"):
|
52
44
|
|
53
|
-
published = article.find(class_="published").string
|
45
|
+
published = article.find(class_="published").string # 記事の日付
|
54
46
|
|
55
|
-
|
47
|
+
if published != today:
|
56
48
|
|
57
|
-
|
49
|
+
continue # 今日の日付でない場合はスキップ
|
58
|
-
|
59
|
-
header = article.find(class_="media-heading")
|
60
50
|
|
61
51
|
|
62
52
|
|
63
|
-
|
53
|
+
# 記事のリンクとタイトルを取得
|
64
54
|
|
65
|
-
|
55
|
+
header = article.find(class_="media-heading")
|
66
56
|
|
67
|
-
print(title)
|
68
57
|
|
69
|
-
msg = title + '\n' + link
|
70
58
|
|
59
|
+
link = header.a["href"]
|
60
|
+
|
61
|
+
title = header.string
|
62
|
+
|
63
|
+
msg = title + '\n' + link
|
64
|
+
|
71
|
-
print(msg)
|
65
|
+
print(msg)
|
72
66
|
|
73
67
|
```
|
74
68
|
|