Question
Python Coding: Use a Web API to get URLs for news articles Go to https://newsapi.org and create an account and get a key. When writing
Python Coding: Use a Web API to get URLs for news articles
Go to https://newsapi.org and create an account and get a key. When writing out the python code, assume API key is: b50a6f10a0134cf19bded255060df1a0.
Write a function getNews(source) that accepts the name of a source, queries the NewsAPI, and returns back a list of URLs with the news stories that appear in that source.
For example, the outcome of the command:
getNews('the-wall-street-journal')
can be the following list:
['https://www.wsj.com/articles/trump-faces-tensions-at-g-7-summit-1495803166', 'https://www.wsj.com/articles/gunmen-in-egypt-attack-bus-carrying-coptic-christians-1495796748', 'https://www.wsj.com/articles/u-k-rolls-up-alleged-accomplices-of-suicide-bomber-1495821597', 'https://www.wsj.com/articles/u-s-gdp-growth-revised-up-to-1-2-rate-in-first-quarter-1495802143', ....]
Follow the documentation at https://newsapi.org/#documentation and figure out how to get the list of articles from various news sources.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started