Golang 网络抓取工具 NTLM 身份验证

Golang web scraper NTLM authentication

Golang 网络抓取工具需要从经过 NTLM 验证的网页中提取信息。

有了有效的用户名和密码,网络爬虫如何与服务器执行 NTLM 4 次握手,以访问后面受保护的网页?

url, username, password := "http://www.some-website.com", "admin", "12345"

client := &http.Client{}
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "NTLM")
res, _ := client.Do(req)

您可以在开始抓取之前使用 Azure/go-ntlmssp 之类的包进行身份验证。

url, username, password := "http://www.some-website.com", "admin", "12345"

client := &http.Client{
    Transport: ntlmssp.Negotiator{
        RoundTripper:&http.Transport{},
    },
}

req, _ := http.NewRequest("GET", url, nil)
req.SetBasicAuth(username, password)

res, _ := client.Do(req)