Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html to .doc converter in Python?

I am using pisa, which is an HTML to PDF conversion library for Python.

Does there exist the same thing for a Word document: an HTML to .doc conversion library for Python?

like image 916
Eric Avatar asked Nov 19 '10 14:11

Eric


1 Answers

You could use win32com from the pywin32 python extensions for windows, to let MS Word convert it for you. A simple example:

import win32com.client

word = win32com.client.Dispatch('Word.Application')

doc = word.Documents.Add('example.html')
doc.SaveAs('example.doc', FileFormat=0)
doc.Close()

word.Quit()
like image 179
Steven Avatar answered Oct 05 '22 22:10

Steven