hello steemians i will be showing you guys how to access google news in python
first off let's import the neccessary modules
import requests
from bs4 import BeautifulSoup as soup
secondly we create a function for accessing the news via google
def feeds(self):
db = [] #this is a list that holds all the news gathered
news_url = "https://news.google.com/news/rss" #google news web directory
Client=requests.get(news_url) #here we make a call to access the contents of the url
xml_page=Client.content #basically returns the contents of the url
soup_page=soup(xml_page,"xml") #for processing webpages in python
news_list=soup_page.findAll("item") #returns all tags "item" in the web page
for news in news_list[:15]:#returns the top 10 news
db.append(news.title.text.encode('utf-8'))
return("here is the top 10 trending news. \n\n%s"%".\n".join(db)) #a return call