网页python脚本问题?

0
代码如下
#!/usr/bin/python

# -*- coding: UTF-8 -*-

import requests

from bs4 import BeautifulSoup

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36'}

r = requests.get('https://movie.douban.com/subject/26862829/?from=showing', headers = headers)

content = r.text

soup = BeautifulSoup(content, 'lxml')

divs = soup.find_all(class_ = 'comment')


print "Content-type:text/html"

print

print '<html>'

print '<head>'

print '<meta charset="utf-8">'

print '<title>Hello Word - 我的第一个 CGI 程序!</title>'

print '</head>'

print "<ul>"

for div in divs:

comment = div.p.get_text()

print '''<li> %s </li>''' % (comment)

print "</ul>"

print '</html>'

脚本可以正常运行,但是放在服务器上后,通过浏览器运行此脚本,不显示for循环里的内容

在本地正常运行后把输出复制到一个html中,再放到服务器上,浏览器可以正常显示,说明html代码没问题啊

求教大神,为什么会这样?
已邀请:

要回复问题请先登录注册