Code: Select all
import deepl
from html.parser import HTMLParser
class MyHTMLParser(HTMLParser):
def handle_starttag(self, tag, attrs):
result = ''
print('start ' + str(result))
for attr in attrs:
print(" attr:", attr)
def handle_endtag(self, tag):
result = ''
print('end ' + str(result))
#print("End tag :", tag)
def handle_data(self, data):
self.translate_data(data)
#print("Data :", data)
Code: Select all
deepl_client = deepl.DeepLClient(auth_key)
#Translate a formal document from English to French
input_path = "blabla"
output_path = "blabla"
parser = MyHTMLParser()
with open(input_path, 'r') as file:
content = file.read()
parser.feed(content)
Mobile version