Я новичок в python, и у меня возникают проблемы с удалением html-тегов из вывода. Я хотел бы удалить теги и содержимое внутри них. Я также хотел бы удалить теги p. Какие-либо предложения?
import urllib2
from bs4 import BeautifulSoup
# Ask user to enter URL
url = raw_input("Please enter a valid URL: ")
# Make sure file is clear for new content
open('ctp_output.txt', 'w').close()
# Open txt document for output
txt = open('ctp_output.txt', 'w')
# Parse HTML of article, aka making soup
soup = BeautifulSoup(urllib2.urlopen(url).read())
# retrieve all of the paragraph tags
tags = soup('p')
txt.write(str(tag) + '\n' + '\n')
# Close txt file with new content added
txt.close()