-
-
Save ryanhugh/76b2de2a900cd763399990f63683a90c to your computer and use it in GitHub Desktop.
This file contains 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
var request = require('request') | |
var dns = require('dns'); | |
dns.lookup('www.google.com', (err, address, family) => { | |
console.log('IP for www.google.com is:', address); | |
let cookieJarWithIp = request.jar() | |
let cookieJarWithDomain = request.jar() | |
request.get({ | |
url: 'https://' + address, | |
followRedirect: false, | |
resolveWithFullResponse: true, | |
headers: { | |
'Host': 'www.google.com', | |
'host': 'www.google.com' | |
}, | |
jar: cookieJarWithIp, | |
}, function (err, resp) { | |
console.log('Cookeis with ip:', cookieJarWithIp.getCookies('https://www.google.com')) | |
console.log('Cookeis with ip:', cookieJarWithIp.getCookies('https://google.com')) | |
debugger | |
}) | |
request.get({ | |
url: 'https://www.google.com', | |
followRedirect: false, | |
resolveWithFullResponse: true, | |
headers: { | |
'Host': 'www.google.com', | |
'host': 'www.google.com' | |
}, | |
jar: cookieJarWithDomain, | |
}, function (err, resp) { | |
console.log('Cookeis with domain:', cookieJarWithDomain.getCookies('https://www.google.com')) | |
console.log('Cookeis with domain:', cookieJarWithDomain.getCookies('https://google.com')) | |
debugger | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment