我有HTTP
回应。我正在尝试使用scala
. 我的代码如下所示:
import scalaj.http.Http
val result = Http("http:///sample.com")
.postData("""{"Username":"user1","password":"pass"""")
.header("Content-Type", "application")
.header("Accept", "text/plain")
val headers = result.headers.mkString
println("Headers: " + headers)
标题如下所示:
Cache-Control -> Vector(no-Store)
Content-Type -> Vector(text/html;charset=ISO-8859-l)
Set-Cookie -> Vector(SESSIONID=D122334;path=/a/b/c;SSO=000112233445)
在此标头中,我想单独提取 SSO 值。使用下面的代码,我可以正确打印它们。
for((k,v) <- result.headers) println(s"key: $k\nvalue: $v\n")
得到以下结果:
key: Cache-Control
value: Vector(no-Store)
key: Content-Type
value: Vector(text/html;charset=ISO-8859-l)
key: Set-Cookie
value: Vector(SESSIONID=D122334;path=/a/b/c;SSO=000112233445)
我想单独提取SSO
under key的数据。Set-Cookie
我知道如何使用 python 来实现这一点
我对 Scala 很陌生。有人可以帮我吗?