supman
V2EX  ›  问与答

java 发送 GET 带 cookie 请求 的正确方式是什么呢?

  •  
  •   supman · Sep 4, 2015 · 3059 views
    This topic created in 3997 days ago, the information mentioned may be changed or developed.
    URL url = new URL (stringURL );
    HttpURLConnection conn = (HttpURLConnection )url.openConnection ();
    conn.setRequestMethod ("GET");
    conn.setRequestProperty ("Cookie", cookie );
    //------------或者这个??? conn.connect ();???
    conn.setDoInput (true );
    conn.setDoOutput (true );

    网上找到的差不多都是这个姿势, 但是显示的结果和 python 版的
    requests.get (url,cookies=cookies )
    并不相同。
    2 replies    2015-09-04 11:03:23 +08:00
    iyangyuan
        1
    iyangyuan  
       Sep 4, 2015 via iPhone
    java 有 CookieStore 吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5295 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 01:21 · PVG 09:21 · LAX 18:21 · JFK 21:21
    ♥ Do have faith in what you're doing.