使用ipv6代理进行节点提取



您知道用ipv6代理使用nodefetch(或类似包(的方法吗?我被困在这个";"小";指向

我试过

const fetch = require('node-fetch');
const HttpsProxyAgent = require('https-proxy-agent');
class Something {
async init (url) {
return fetch(url, {agent: new HttpsProxyAgent('https://2a01:cb00:8612:c000:86d:5188:7abc:4c2f')})
.then(res => res.text())
}
}

但不起作用(令人惊讶…(

得到:

failed, reason: getaddrinfo ENOTFOUND 2a01

我确信我在做一些愚蠢的事情,但我不明白我能用ipv6做什么或不能做什么…

您在URL中的IPv6地址文本格式不正确。您需要将IPv6地址用括号([](括起来:

https://[2a01:cb00:8612:c000:86d:5188:7abc:4c2f]

这在RFC 2732中有解释,URL中的文字IPv6地址格式:

2.URL语法中的IPv6地址格式

若要在URL中使用文字IPv6地址,文字地址应为封闭在";["one_answers"]";字符。例如以下文字IPv6地址:

FEDC:BA98:7654:3210:FEDC:BA98:7654:3210
1080:0:0:0:8:800:200C:4171
3ffe:2a00:100:7031::1
1080::8:800:200C:417A
::192.9.5.5
::FFFF:129.144.52.38
2010:836B:4179::836B:4179

将表示为以下示例URL:

http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
http://[1080:0:0:0:8:800:200C:417A]/index.html
http://[3ffe:2a00:100:7031::1]
http://[1080::8:800:200C:417A]/foo
http://[::192.9.5.5]/ipng
http://[::FFFF:129.144.52.38]:80/index.html
http://[2010:836B:4179::836B:4179]

最新更新