initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
using proxy with fetch
|
||||
https://www.zenrows.com/blog/node-fetch-proxy#how-to-use-proxy-with-node-fetch
|
||||
for username and password
|
||||
https://github.com/TooTallNate/proxy-agents/issues/12
|
||||
|
||||
|
||||
```js
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const proxyUrl = 'http://proxyserver:port';
|
||||
const proxyOptions = {
|
||||
proxy: proxyUrl,
|
||||
headers: {
|
||||
'Proxy-Authorization': 'Basic ' + Buffer.from('username:password').toString('base64')
|
||||
}
|
||||
};
|
||||
|
||||
fetch('http://url-to-fetch', proxyOptions)
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
Same with curl
|
||||
`curl -x http://proxyserver:port --proxy-user username:password http://url-to-fetch`
|
||||
for socks5
|
||||
`curl -v --socks5 127.0.0.1:1080 https://icanhazip.com`
|
||||
replace with socks4 for socks4
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in a new issue