Golang Web刮板NTLM认证 [英] Golang web scraper NTLM authentication

查看:281
本文介绍了Golang Web刮板NTLM认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

A Golang web scraper needs to extract information from a webpage that is NTLM-authenticated.

拥有一个有效的用户名&密码,网络抓取工具如何与服务器执行NTLM 4次握手以访问受保护的网页?

Having a valid username & password, how can the web scraper perform the NTLM 4-way handshake with the server in order to gain access to the protected webpage behind?

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 在开始之前进行身份验证

You can use a package like Azure/go-ntlmssp to authenticate before you start scraping.

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)

这篇关于Golang Web刮板NTLM认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆