~jonjfineman/rssFeed

6d4a8a821faaa5790f0949343693067b6aa17a14 — Jon Fineman 2 months ago 7d221c9
track npr.org url change
1 files changed, 9 insertions(+), 3 deletions(-)

M rssFeed.py
M rssFeed.py => rssFeed.py +9 -3
@@ 303,7 303,11 @@ for rss in rssList['list']:
				messageBody += '<p>Summary:</p>'
				messageBody += '<p>' + str(description) + '</p>'
				content_value = description
				story_url = str(link).replace("www.npr.org", "text.npr.org")
				story_url = str(link).replace("npr.org", "text.npr.org")
				if DEBUG == True:
					print('\n\n**** regx:\n', str(link).replace("npr.org", "text.npr.org"))
					print('\n\n**** html story url:\n', str(link))
					print('\n\n**** text story url:\n', story_url)
				try:
					req = urllib.request.Request(story_url)
					req.add_header('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.100 Safari/537.36')


@@ 459,7 463,8 @@ for rss in rssList['list']:
		messageText += "\n" + summary + "\n\n"
		# see if we can swap url for a lite version
		# @TODO make configureable
		messageText = messageText.replace("www.npr.org", "text.npr.org", 1)
		messageText = messageText.replace("npr.org", "text.npr.org", 1)
		### messageText = messageText.replace("www.npr.org", "text.npr.org", 1)
		### messageText = messageText.replace("www.reddit.com", "i.reddit.com")
		if DEBUG == True:
			print('\n\n**** text msg:\n', messageText)


@@ 483,7 488,8 @@ for rss in rssList['list']:
		messageHTML += '</html>'
		# see if we can swap url for a lite version
		# @TODO make configureable
		messageHTML = messageHTML.replace("www.npr.org", "text.npr.org", 2)
		messageHTML = messageHTML.replace("npr.org", "text.npr.org", 2)
		### messageHTML = messageHTML.replace("www.npr.org", "text.npr.org", 2)
		messageHTML = messageHTML.replace("www.reddit.com", "i.reddit.com")
		if DEBUG == True:
			print('\n\n**** html msg:\n', messageHTML)