1
我有以下代碼,它使用http://fsharp.github.io/FSharp.Data/library/Http.html登錄網站並獲取一些文件。但是,每個頁面都有一個用於設置cookie的jQuery腳本 - $.cookie("Authenticated", 14313432);
。我的代碼必須模仿jQuery腳本來設置cc
。否則認證將失敗。如何使用F#Data:HTTP Utilities?如何設置cookie?
let cc = CookieContainer()
let h = Http.RequestString(url, httpMethod = "GET", cookieContainer = cc, headers = headers) // embedded jQuery will set the cookie
let body = HttpRequestBody.FormValues ["UserName", "xxx"; "Password", "ppp"]
Http.RequestString(url, body=body, httpMethod="POST", cookieContainer=cc, headers = ...
let page = Http.RequestString(....) // embedded jQuery script will set the cookie with different value
let page2 = Http.RequestString(....) // embedded jQuery script will set the cookie with different value