dqbhdsec59405 2016-02-24 05:24
浏览 271

如何在Golang中查看cookieJar的内容?

I'm trying to view the contents of a cookieJar response from a request to google:

package main

import (
    "fmt"
    "log"
    "net/http"
    "net/http/cookiejar"
    "net/url"
)

func main() {

    jar, err := cookiejar.New(nil)
    if err != nil {
        log.Fatal(err)
    }
    client := http.Client{Jar: jar}
    resp, err := client.Get("https://accounts.google.com/ServiceLogin?continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Ffeature%3Dsign_in_button%26hl%3Den%26action_handle_signin%3Dtrue%26next%3D%252F%26app%3Ddesktop&service=youtube&sacu=1&passive=1209600&ignoreShadow=0&acui=0#identifier")
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(resp.Cookies())

    s := ".google.com"
    u, err := url.Parse(s)
    fmt.Println(client.Jar.Cookies(u))

}

The response is a blank array but I can see that there are cookies being set. How do I view the contents of a cookieJar in Golang?

  • 写回答

1条回答 默认 最新

  • douyi9597 2016-02-24 06:41
    关注

    Unfortunately not, the cookie jar in the std library is completely opaque and can be queried via (non-wildcard) URLs only.

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作