In the future, (maybe still far away, due to the fact that I'm still a novice) I want to do data analysis, based on the content of the news I get from the Google News RSS, but for that, I need to have access to that content, and that is my problem.
Using the URL "https://news.google.cl/news/rss" I have access to data like the title, and the URL of each news item, but the URL is in a format that does not allow me to scrape it (https://news.google.com/__i/rss/rd/articles/CBMilgFod...).
news_url="https://news.google.cl/news/rss"
Client=urlopen(news_url)
xml_page=Client.read()
Client.close()
soup_page=soup(xml_page,"xml")
news_list=soup_page.findAll("item")
for news in news_list:
print(news.title.text)
print("-"*60)
response = urllib.request.urlopen(news.link.text)
html = response.read()
soup = soup(html,"html.parser")
text = soup.get_text(strip=True)
print(text)
The last print(text)
prints some code like:
if(typeof bbclAM === 'undefined' || !bbclAM.isAM()) {
googletag.display('div-gpt-ad-1418416256666-0');
} else {
document.getElementById('div-gpt-ad-1418416256666-0').st
yle.display = 'none'
}
});(function(s, p, d) {
var h=d.location.protocol, i=p+"-"+s,
e=d.getElementById(i), r=d.getElementById(p+"-root"),
u=h==="https:"?"d1z2jf7jlzjs58.cloudfront.net"
:"static."+p+".com";
if (e) return;
I expect to print the title and the content of each news item from the RSS