Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
HackerX-OP authored Jan 9, 2024
0 parents commit 4cc13e3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import requests
import json
import os
import time

month = time.strftime('%m')
year = time.strftime('%Y')

date = time.strftime('%d')
date = int(date) - 1

query = input("On which topic you want to search news: ")
url = f"https://newsapi.org/v2/everything?q={query}&from={year}-{month}-{date}&sortBy=publishedAt&apiKey=424ae6b58d7548ffbfb1e47e0b160281"

news = requests.get(url)

news_dic = json.loads(news.text)
data = news.json()
for i in range(11):
articles = data.get('articles')

title = articles[i].get('title')
author = articles[i].get('author')
desc = articles[i].get('description')

print(title)
print(desc)
print("------------------------------------------------------------")

0 comments on commit 4cc13e3

Please sign in to comment.