質問編集履歴

1

コードのインデントを整えました

2019/06/04 14:14

投稿

Quad
Quad

スコア18

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
- if published != today:
47
+ if published != today:
56
48
 
57
- continue
49
+ continue # 今日の日付でない場合はスキップ
58
-
59
- header = article.find(class_="media-heading")
60
50
 
61
51
 
62
52
 
63
- link = header.a["href"]
53
+ # 記事のリンクとタイトルを取得
64
54
 
65
- title = header.string
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