Ich habe den folgenden Code, den ich verwende, um zu versuchen und den Titel und die Beschreibung von den redsox Nachrichten zu erhalten. Ich habe es funktioniert, aber für ein kleines Detail. Es zeigt die Tags. Wie kann ich sie beseitigen?Python und BeautifulSoup URL parse
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)
Dies ist, was es
Title: <title>Shaw or Panda? Hot corner duel heats up</title>
Summary: <description>With two weeks until Opening Day, the hottest topic in Red Sox camp is the competition at the hot corner between incumbent Pablo Sandoval and the emerging Travis Shaw.</description>
>>>
http://stackoverflow.com/questions/16206380/python-beautifulsoup-how-to-remove-all-tags-from-an-element –
Könnte die Dokumentation lesen wollen http://www.crummy.com/software/BeautifulSoup/bs4/doc/# get-text –