스터디/Etc

nodejs tor proxy

Dalmangyi 2024. 4. 17.

 

 

1. tor 브라우저까지 깔 필욘 없지만 테스트를 위해서 깔아도 좋음.

2. "$brew install tor" 명령어로 tor 설치

3. 터미널에서 "$tor" 명령어 실행해서 tor 실행하기.

4. "$sudo lsof -i :9050" 명령어로 가동중인지 확인

 프로세스 죽일려면 PID를 이용해서 "$sudo kill -9 ${PID}" 하면됨.

 (이런식임 "$sudo kill -9 14223")

 

5. npm 패키지 설치

$npm i axios

$npm i socks-proxy-agent

 

6. import

import axios from 'axios'; 

import { SocksProxyAgent } from 'socks-proxy-agent';

 

7. nodejs 코드

const httpsAgent = new SocksProxyAgent('socks://127.0.0.1:9050'); 

const result = await axios({
    httpsAgent,
    method:'get',
    url:`https://test.com`
})

 

 

댓글