Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13921

How to compare two HTML files in python and print only the differences?

$
0
0

I have two HTML reports generated from sonar showing the issues in my code.

Problem Statement: I need to compare two sonar reports and find out the differences i.e. new issues that got introduced. Basically need to find differences in html and print those differences only.

I tried a few things:

import difflibfile1 = open('sonarlint-report.html', 'r').readlines()file2 = open('sonarlint-report_latest.html', 'r').readlines()htmlDiffer = difflib.HtmlDiff()htmldiffs = htmlDiffer.make_file(file1, file2)with open('comparison.html', 'w') as outfile:    outfile.write(htmldiffs)

Now this gives me a comparison.html which is nothing but two html diff. Doesn't print only the different lines.

Should I try HTML parsing and then somehow get the differences only to be printed?


Viewing all articles
Browse latest Browse all 13921

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>