2016-11-08 25 views
2

Golang網絡抓取工具需要從經過NTLM認證的網頁中提取信息。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) 

回答

3

在開始抓取之前,您可以使用像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) 
+0

謝謝,先生! –