Skip to content

Instantly share code, notes, and snippets.

@nikhilkumarsingh
Created June 29, 2017 13:31
Show Gist options
  • Save nikhilkumarsingh/9c0b71da07c871e2a6af5d853fda5484 to your computer and use it in GitHub Desktop.
Save nikhilkumarsingh/9c0b71da07c871e2a6af5d853fda5484 to your computer and use it in GitHub Desktop.
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)
@vijaymannava
Copy link

thanq ...excellent explanation...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment