Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 如何设置cookie?_F#_Httprequest_F# Data - Fatal编程技术网

F# 如何设置cookie?

F# 如何设置cookie?,f#,httprequest,f#-data,F#,Httprequest,F# Data,我有以下代码,用于登录网站并获取一些文件。但是,每个页面都有一段jQuery脚本来设置cookie-$.cookie(“Authenticated”,14313432)。我的代码必须模仿jQuery脚本来设置cc。否则,身份验证将失败。如何使用F#Data:HTTP实用程序实现 let cc = CookieContainer() let h = Http.RequestString(url, httpMethod = "GET", cookieContainer = cc, headers =

我有以下代码,用于登录网站并获取一些文件。但是,每个页面都有一段jQuery脚本来设置cookie-
$.cookie(“Authenticated”,14313432)。我的代码必须模仿jQuery脚本来设置
cc
。否则,身份验证将失败。如何使用F#Data:HTTP实用程序实现

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

如果我没弄错的话,你不知道如何插入
“Authenticated”,14313432
作为cookie,但你找到了如何使用
CookieContainer
对吗

这个类只是一个包含对象的.net类,所以这应该可以做到:

let cc = CookieContainer()
let cookie = Cookie ("Authenticated", "14313432")
cc.Add cookie
// the rest of your code