We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7bb8ba3 commit 5e4fc44Copy full SHA for 5e4fc44
web_programming/fetch_bbc_news.py
@@ -0,0 +1,18 @@
1
+# Created by sarathkaul on 12/11/19
2
+
3
+import requests
4
5
+# Enter Your API Key in following URL
6
+_NEWS_API = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey="
7
8
9
+def fetch_bbc_news(bbc_news_api_key: str) -> None:
10
+ # fetching a list of articles in json format
11
+ bbc_news_page = requests.get(_NEWS_API + bbc_news_api_key).json()
12
+ # each article in the list is a dict
13
+ for i, article in enumerate(bbc_news_page["articles"], 1):
14
+ print(f"{i}.) {article['title']}")
15
16
17
+if __name__ == '__main__':
18
+ fetch_bbc_news(bbc_news_api_key="<Your BBC News API key goes here>")
0 commit comments