Created
June 29, 2017 13:31
-
-
Save nikhilkumarsingh/9c0b71da07c871e2a6af5d853fda5484 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "http://www.hindustantimes.com/rss/topnews/rssfeed.xml" | |
resp = requests.get(url) | |
soup = BeautifulSoup(resp.content, features="xml") | |
items = soup.findAll('item') | |
news_items = [] | |
for item in items: | |
news_item = {} | |
news_item['title'] = item.title.text | |
news_item['description'] = item.description.text | |
news_item['link'] = item.link.text | |
news_item['image'] = item.content['url'] | |
news_items.append(news_item) | |
print(news_items) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanq ...excellent explanation...