seawolf2357 commited on
Commit
30b6d7e
ยท
verified ยท
1 Parent(s): b165d44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,21 +3,21 @@ from gnewsclient import gnewsclient
3
  from datetime import datetime, timedelta
4
 
5
  # Google ๋‰ด์Šค ํด๋ผ์ด์–ธํŠธ ์ดˆ๊ธฐํ™”
6
- client = gnewsclient.NewsClient()
7
 
8
  # ์ง€์›๋˜๋Š” ๊ตญ๊ฐ€ ๋ชฉ๋ก
9
  supported_countries = client.locations
10
 
11
  def get_news(country, keyword):
12
- # ๊ตญ๊ฐ€ ์„ค์ •
13
  client.location = country
14
- client.language = 'en' # ์˜์–ด๋กœ ์„ค์ •
15
 
16
  # ํ˜„์žฌ ์‹œ๊ฐ„ ๊ธฐ์ค€ 24์‹œ๊ฐ„ ์ „ ์‹œ๊ฐ„ ๊ณ„์‚ฐ
17
  time_threshold = datetime.now() - timedelta(hours=24)
18
 
19
  # ๋‰ด์Šค ๊ฒ€์ƒ‰
20
- news_items = client.get_news(keyword)
21
 
22
  # 24์‹œ๊ฐ„ ์ด๋‚ด์˜ ๋‰ด์Šค๋งŒ ํ•„ํ„ฐ๋งํ•˜๊ณ  ์ œ๋ชฉ๊ณผ ๋งํฌ ์ถ”์ถœ
23
  filtered_news = []
 
3
  from datetime import datetime, timedelta
4
 
5
  # Google ๋‰ด์Šค ํด๋ผ์ด์–ธํŠธ ์ดˆ๊ธฐํ™”
6
+ client = gnewsclient.NewsClient(language='en', location='', topic='', max_results=10)
7
 
8
  # ์ง€์›๋˜๋Š” ๊ตญ๊ฐ€ ๋ชฉ๋ก
9
  supported_countries = client.locations
10
 
11
  def get_news(country, keyword):
12
+ # ๊ตญ๊ฐ€ ๋ฐ ํ‚ค์›Œ๋“œ ์„ค์ •
13
  client.location = country
14
+ client.query = keyword
15
 
16
  # ํ˜„์žฌ ์‹œ๊ฐ„ ๊ธฐ์ค€ 24์‹œ๊ฐ„ ์ „ ์‹œ๊ฐ„ ๊ณ„์‚ฐ
17
  time_threshold = datetime.now() - timedelta(hours=24)
18
 
19
  # ๋‰ด์Šค ๊ฒ€์ƒ‰
20
+ news_items = client.get_news()
21
 
22
  # 24์‹œ๊ฐ„ ์ด๋‚ด์˜ ๋‰ด์Šค๋งŒ ํ•„ํ„ฐ๋งํ•˜๊ณ  ์ œ๋ชฉ๊ณผ ๋งํฌ ์ถ”์ถœ
23
  filtered_news = []