F# 如何设置cookie?
我有以下代码,用于登录网站并获取一些文件。但是,每个页面都有一段jQuery脚本来设置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 =
$.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