• 请不要在回答技术问题时复制粘贴 AI 生成的内容
sandman511
V2EX  ›  程序员

Java Jsoup 爬取网页时提示 Session 过期。求助

  •  
  •   sandman511 · Jan 3, 2020 · 2119 views
    This topic created in 2501 days ago, the information mentioned may be changed or developed.

    该网页必须登陆才能查询 无验证码

        public static void main(String[] args) throws IOException {
            //获取 Cookies
            Connection.Response res = Jsoup.connect("https://马赛克 /Login.do")
                                           .data("userID","马赛克","password","马赛克")
                                           .method(Connection.Method.POST)
                                           .execute();
            Map<String,String> cookiesMap =res.cookies();
    
            //带 Cookies 查询
            Document document = Jsoup.connect("https://马赛克 /KeySearcherAction.do")
                                     .data("location","马赛克")
                                     .cookies(cookiesMap).post();
            System.out.println(document.body().tagName("tbody").tagName("tr").tagName("td"));
        }
    

    但是带上 Cookies 后页面依然提示

    The session carried out the timeout or unjust page changes were performed.
    

    我用 POSTMAN 挂上 Cookies 也是如此
    unjust page changes were performed 这句话是非法行为的意思?
    求助 感谢!

    matepi
    matepi
    Jan 3, 2020 via iPhone
    1
    抓包比对
    fmumu
    fmumu
    Jan 3, 2020 via Android
    2
    请求头之类的看看
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1588 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 08:38 · PVG 16:38 · LAX 00:38 · JFK 03:38
    ♥ Do have faith in what you're doing.