Created
October 20, 2020 03:48
-
-
Save hasegawayosuke/13776584718fb56cba2f9c8c5c100e9d to your computer and use it in GitHub Desktop.
got with proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const got = require('got') | |
const myGot = async (url) => { | |
const instance = got.extend({ | |
hooks: { | |
beforeRequest: [ | |
options => { | |
options.headers.Host = (new URL(url)).hostname | |
options.port = 8888 | |
options.hostname = '127.0.0.1' | |
options.url = url | |
} | |
] | |
} | |
}) | |
const response = await instance(url) | |
console.log(response) | |
} | |
myGot('http://utf-8.jp/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment