Python help in VScode converting txt to tei

New to coding so my apologies if my code is a mess. I am trying to convert a txt file to a tei file so I can analyze it further but previously I have been using xml to tei. Here is the code I have below and the error message. So I know I need to do something different to get it to analyze a txt file but I’m not sure which way would be the most efficient way to do so. Any help is much appreciated!

with open(“dracula.txt”, “r”, encoding=“utf8”) as input:
soup = bs(input, “txt”)
body = soup.find(“body”)
tei_header = soup.find(“teiHeader”)
title = tei_header.find(“title”).string
with open(“dracula.tei”, “w”) as output:

Error: Couldn’t find a tree builder with the features you requested: txt.

The error message suggests something is missing, here: soup = bs(input, “txt”).

Generally, it’s something like this:
soup = BeautifulSoup(webpage, "html.parser")

What parser are you using to read the HTML? You could use lxml maybe(?)



To extract certain pieces of text from the file object, you’d have to use something like,
.get_text() or,
to get all the text: print(soup.get_text())

Again, the documentation linked above is helpful. And i believe the info is also in the CC ‘Build a Web Scraper’ course.