google news via python
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
Leave google news via python to:
Read more #diy posts
Best Posts From nacbotics
We have not curated any of nacbotics's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From nacbotics
- CryptoPop - Earn Free ETH - Earn Ethereum and Popcoin by playing this game
- Samaritan Clever Bot- [APP] - Talking to AI friend has never been this fun and realistic
- Making A FORK bomb in python
- Who Do I Follow on Steem & Why?
- ALL NEW REVIEW HUNT
- LOL Hunt
- Transno
- DROPS SCRIPTS
- BRAVE BROWSER
- NESTREE
- Wordmoji
- Ember Social media for gamers
- TATA
- ALTCOIN FANTASY
- review hunt
- google news via python