Using the difflib.HtmlDiff class - display individual characters

I use a class difflib.HtmlDiffby calling a function using two typesetting (HTML from websites), however, when it makes a table

html_diff = difflib.HtmlDiff()
print html_diff.make_table(previous_contents, fetch_url.page_contents)

however, it seems that the comparison is char from char (1 char per table row), and in the end I get a file in 4.3MB format for two sets of html, which are only 100k.

The doc file says:

Compares fromlines and tolines (lists of strings) and returns a string which is a 
complete HTML file containing a table showing line by line differences with 
inter-line and intra-line changes highlighted.

however, this does not seem to be the case.

Any suggestions?

+3
source share
1 answer

You supply strings, not lists of strings (strings).

Assuming the end of UNIX or Windows ends:

print html_diff.make_table(previous_contents.split('\n'),
                           fetch_url.page_contents.split('\n'))
+4
source

All Articles