Reputation: 31
I'm using npm got
package to do web scraping and I want to use a SOCKS proxy. The docs have this snippet about using proxies:
import got from 'got';
import {HttpsProxyAgent} from 'hpagent';
await got('https://sindresorhus.com', {
agent: {
https: new HttpsProxyAgent([skipped by me])
}
});
So I've tried using socks-proxy-agent
, but apparently the agent
property of got only supports http
, https
and http2
keys.
How do I make got use my SOCKS agent?
Upvotes: 3
Views: 988
Reputation: 1125
agent property of got only supports http, https and http2 keys.
These are used to specify which agent should got
use to fetch that kind of a resource. You can use a socks agent for each of these:
await got('https://sindresorhus.com', {
agent: {
http: yourSOCKSAgent,
https: yourSOCKSAgent
}
});
Upvotes: 0