Skip to content

Commit af3a2ea

Browse files
Merge pull request #449 from cclauss/patch-1
Fix TabError for Python 3
2 parents 30af8d0 + 1321cde commit af3a2ea

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Google_News.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@
55
from urllib.request import urlopen
66

77
def news(xml_news_url):
8-
9-
'''Print select details from a html response containing xml
10-
@param xml_news_url: url to parse
11-
'''
12-
13-
context = ssl._create_unverified_context()
14-
Client=urlopen(xml_news_url, context=context)
15-
xml_page=Client.read()
16-
Client.close()
17-
18-
soup_page=soup(xml_page,"xml")
19-
20-
news_list=soup_page.findAll("item")
21-
22-
for news in news_list:
23-
print(f'news title: {news.title.text}')
24-
print(f'news link: {news.link.text}')
25-
print(f'news pubDate: {news.pubDate.text}')
26-
print("+-"*20,"\n\n")
27-
28-
#you can add google news 'xml' URL here for any country/category
8+
9+
'''Print select details from a html response containing xml
10+
@param xml_news_url: url to parse
11+
'''
12+
13+
context = ssl._create_unverified_context()
14+
Client=urlopen(xml_news_url, context=context)
15+
xml_page=Client.read()
16+
Client.close()
17+
18+
soup_page=soup(xml_page,"xml")
19+
20+
news_list=soup_page.findAll("item")
21+
22+
for news in news_list:
23+
print(f'news title: {news.title.text}')
24+
print(f'news link: {news.link.text}')
25+
print(f'news pubDate: {news.pubDate.text}')
26+
print("+-"*20,"\n\n")
27+
28+
#you can add google news 'xml' URL here for any country/category
2929
news_url="https://news.google.com/news/rss/?ned=us&gl=US&hl=en"
3030
sports_url="https://news.google.com/news/rss/headlines/section/topic/SPORTS.en_in/Sports?ned=in&hl=en-IN&gl=IN"
3131

3232
#now call news function with any of these url or BOTH
33-
news(news_url)
33+
news(news_url)
3434
news(sports_url)

0 commit comments

Comments
 (0)