我有下面的代码,我用它来尝试从redsox新闻中获取标题和描述。我有它的工作,但有一个小细节。它显示了标签。我怎样才能消除他们?在
import urllib2
from BeautifulSoup import BeautifulSoup
# or if you're using BeautifulSoup4:
# from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib2.urlopen('http://partner.mlb.com/partnerxml/gen/news/rss/bos.xml').read())
title = soup.find('item').title
desc = soup.find('item').description
print "Title: %s " % (title)
print "Summary: %s " % (desc)
这就是它所显示的
^{pr2}$
尝试:
你可以用beauthoulsoup做得更好,但这是让它发挥作用的快速方法。在
相关问题 更多 >
编程相关推荐