我正在尝试从启用了 Windows 身份验证的 IIS 托管的页面中获取一些 html。
到目前为止,我有:
open FSharp.Data
[<EntryPoint>]
let main argv =
let html = Http.RequestString ("http://mywebsite.com/Detail.aspx", query=[("zip","9000");("date","11/01/2017")], headers=[???])
printf "%s" html
System.Console.ReadLine() |> ignore
0 // return an integer exit code
Run Code Online (Sandbox Code Playgroud)
我需要在标题列表中添加什么?
我同意 Anton 的观点,如果您需要进一步定制,那么使用原始 .NET API 来发出请求可能会更容易。也就是说,RequestString确实有一个参数customizeHttpRequest,它允许您指定一个函数,该函数在发送请求之前设置请求的其他属性,因此您可以使用以下内容来设置该Credentials属性:
open System.Net
let html =
Http.RequestString("http://mywebsite.com/Detail.aspx",
query=[("zip","9000");("date","11/01/2017")],
customizeHttpRequest = fun r ->
r.Credentials <- new NetworkCredential( "username", "password", "domain" )
r)
Run Code Online (Sandbox Code Playgroud)
有关要配置哪些属性的更多信息,请查看Anton 在评论中提到的.NET 问题。
| 归档时间: |
|
| 查看次数: |
475 次 |
| 最近记录: |