Prakash’s Blog

Innovation Explored

Prakash’s Blog header image 2

Build your Google News SiteMap using Python,Zope

March 9th, 2008 · 2 Comments

Here is a small piece of code in Python – Zope using MySQL as the database. This will help you build a Google News Sitemap in 2 minutes.
# Import a standard function, and get the HTML request and response objects.
from Products.PythonScripts.standard import html_quote
request = container.REQUEST
response = request.RESPONSE
response.setHeader('Content-Type', 'text/xml')
print ''
print '
for item in context.sql.getNewsForToday():
print ‘
build_url = “http://www.yoursite.com/news/”+str(item.news_id)+”.html?google”
print ‘%s‘%build_url
print ‘
#date w3c format
print ‘%s‘%(DateTime(item.post_date).HTML4())
print ‘%s‘ %(item.keywords)
print ‘

print ‘

print ”
return printed

Tags: Python · Zope

2 responses so far ↓

  • 1 David // Mar 22, 2008 at 11:24 am

    I already have google sitemap , why a new news sitemap?

  • 2 Prakash // Mar 22, 2008 at 11:28 am

    If you are a news publisher or magazine publisher having a google news sitemap will help google to crawl pages faster ;)

Leave a Comment