#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import cgi
import string
import feedparser
count = 0
print "Content-Type: text/html\n\n"
print """<PRE><B>WORK MAINTENANCE/B></PRE>"""
d = feedparser.parse("http://www.hep.hr/ods/rss/radovi.aspx?dp=zagreb")
for opis in d:
try:
print """<B>Place/Time:</B> %s<br>""" % d.entries[count].title
print """<B>Streets:</B> %s<br>""" % d.entries[count].description
print """<B>Published:</B> %s<br>""" % d.entries[count].date
print "<br>"
count+= 1
except:
pass
我对 CGI 和 paython 脚本有疑问。在终端脚本下运行得很好,除了“IndexError:list index out of range”,我为此设置了通行证。但是当我通过 CGI 运行脚本时,我只得到 WORK MAINTENANCE 行和 d.entries[count].title 中的第一行重复 9 次?好混乱……
另外,我如何在 feedparser 中设置对克罗地亚(巴尔干)字母的支持;č,ć,š,ž,đ ? # - - 编码:utf-8 - - 不工作,我正在运行 Ubuntu 服务器。
提前感谢您的帮助。
问候。