I have been trying to modify a program I found that gives you three random top news headlines. Heres the code:
import bs4
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen
import random
news_url="https://news.google.com/news/rss"
Client=urlopen(news_url)
xml_page=Client.read()
Client.close()
soup_page=soup(xml_page,"xml")
news_list=soup_page.findAll("item")
# Print news title, url and publish date
news_list = random.choice(news_list)
for news_list in range(3):
for news in news_list:
print(news.title.text)
print(news.link.text)
print(news.pubDate.text)
print("-"*60)
And heres the error I get with the code:
Traceback (most recent call last):
File "newsstuff.py", line 16, in <module>
for news in news_list:
TypeError: 'int' object is not iterable
I hope someone can help thanks!