google news via python

in #diylast year

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 = "" #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
return("here is the top 10 trending news. \n\n%s"%".\n".join(db)) #a return call


Congratulations @nacbotics! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

The new SteemFest⁴ badge is ready
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Welcome nacbotics!
eSteem is the application that improves your experience on Steem. You have full control over your data and content, unlike some apps we don't use our users to promote our application or services.

We have Mobile application for Android and iOS users. We also have developed Surfer Desktop application that helps you to gain new followers and stay connected with your friends, unique features - notifications, bookmarks, favorites, drafts, and more.
We reward our users with encouragement upvotes as well as monthly giveaways rewarding Spotlight top users and active Discord users.
Learn more:
Join our discord: