Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare html responses using node js

Tags:

html

node.js

I have a case where I send a request to a server and record the response. Then I craft the request and send it to server one more time and compare the response with the earlier recorded response.

I am using node.js and I want to know is there any best routine to compare HTML response in node.js which can directly point me the differences in both HTML responses.

like image 306
Gaurav Avatar asked Jun 12 '13 10:06

Gaurav


People also ask

How do I compare two HTML documents?

To compare HTML s and verify how our Java library works, simply load the files you want to diff and select the export file format. After comparing two files, the document containing the difference of this comparison will be automatically loaded.

Can I use HTML with node js?

You can't "run html file" with node. js. Node. js is a JavaScript environment for developing server-side Web applications.

How do I combine HTML and node JS?

http = require('http'); var url = require('url'); var htmlencode = require('htmlencode'); var port = process. env. PORT || 3000; var request = function(req, res) { res. writeHead(200, {'Content-Type': 'text/html'}); var parsed_url = url.

What is setHeader in node JS?

setHeader(name, value) (Added in v0. 4.0) method is an inbuilt application programming interface of the 'http' module which sets a single header value for implicit headers. If this header already exists in the to-be-sent headers, its value will be replaced.


1 Answers

Take a look at jsdiff, it can return to you the differences between two pieces of text, or HTML in your case, at a few different levels (chars, words, lines).

like image 50
Matt Cain Avatar answered Oct 06 '22 20:10

Matt Cain