There are several ways you could achieve this goal. This should get you started (using node.js). In the following example I am fetching google.com and replacting all instances of "google" with "foobar".
// package.json file...
{
"name": "proxy-example",
"description": "a simple example of modifying response using a proxy",
"version": "0.0.1",
"dependencies": {
"request": "1.9.5"
}
}
// server.js file...
var http = require("http")
var request = require("request")
var port = process.env.PORT || 8001
http.createServer(function(req, rsp){
var options = { uri: "http://google.com" }
request(options, function(err, response, body){
rsp.writeHead(200)
rsp.end(body.replace(/google/g, "foobar"))
})
}).listen(port)
console.log("listening on port " + port)
Internet -> Proxy -> wget