简体   繁体   English

如何使用python比较两个html文件并仅显示新html文件中的差异

[英]How to compare two html files and show only the differences in a new html file using python

I have used difflib but the html_table line is taking forever to execute. 我使用了difflib,但是html_table行花了很长时间才能执行。

import difflib

html_1 = data1
html_2 = data2

htmldiff = difflib.HtmlDiff()
html_table = htmldiff.make_table([html_1], [html_2])

I have tried htmldiffer but it is giving me ValueError: stat: path too long for Windows 我尝试了htmldiffer,但是它给了我ValueError:stat:Windows路径太长

from htmldiffer import diff

str_a = data1
str_b = data2
d = diff.HTMLDiffer(data1, data2)

print(d.combined_diff)

I have tried htmltreediff it is giving NameError: name 'basestring' is not defined 我试过htmltreediff它给出NameError:未定义名称'basestring'

from htmltreediff import diff
print (diff(data1, data2 , pretty=True))

This is how to make long file paths available on windows: https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/ 这是使长文件路径在Windows上可用的方法: https : //www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/

CPython issues related to difflib: 与difflib有关的CPython问题:

Solution for long chunks would be to split them into smaller parts and process separately. 长块的解决方案是将它们分成较小的部分并分别处理。 This way quadratic time will be smaller and we still can benefit from _fancy_helper logic. 这样二次时间会更短,我们仍然可以从_fancy_helper逻辑中受益。

htmltreediff - does not support python 3 htmltreediff不支持python 3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何比较python中的两个HTML文件并仅打印差异? - How to compare two HTML files in python and print only the differences? 如何按列比较两个CSV文件并使用Pandas Python将CSV文件中的差异保存 - How to compare two CSV files by column and save the differences in csv file using pandas python Python difflib比较两个csv文件并突出显示HTML输出中的世界级差异 - Python difflib to compare two csv files and highlight the world level differences in HTML output 比较两个文件以了解python中的差异 - Compare two files for differences in python 如何比较两个 JSON 文件并创建一个具有第一个文件差异的新文件? - How to compare two JSON files and create a new file with the differences of first file? 使用 Python 减去/比较两个音频文件之间的差异 - Subtract/compare differences between two audio files using Python 如何在 Python 中将文件中的差异写入新文件? - How to write differences in files to new file in Python? 使用 Difflib 比较 Python 中的两个不同 JSON,仅显示差异 - Compare Two Different JSON In Python Using Difflib, Showing Only The Differences 如何使用python来区分两个html文件 - how to using python to diff two html files 比较字典并仅显示Python中的差异? - Compare dictionaries and show only the differences in Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM