首页 > 解决方案 > 使用 Jsoup 进行网页抓取,无法获取搜索结果

问题描述

我正在尝试从网站https://www.friends2support.org/inner/news/searchresult.aspx抓取捐赠者名单,但无法获取搜索结果页面。任何人都可以看看我的代码,看看有什么问题。

        Connection.Response Form = Jsoup.connect(URL)
        .method(Connection.Method.GET)
        .userAgent(USER_AGENT)
        .execute();
        Document Doc = Form.parse();

        HashMap<String, String> cookies = new HashMap<>(Form.cookies());

        HashMap<String, String> searchData = new HashMap<>();
        searchData.put("dpBloodGroup", "O+");
        searchData.put("dpCountry", "1|dpCountry");
        searchData.put("dpState", "4|dpState");
        searchData.put("dpDistrict", "0|dpDistrict");
        searchData.put("dpCity", "0|dpCity");
        searchData.put("btnSearchButton", "Submit");

        Connection.Response result = Jsoup.connect(URL)
                .cookies(cookies)
                .data(searchData)
                .method(Connection.Method.POST)
                .userAgent(USER_AGENT)
                .execute();

        System.out.println(result.parse().html());

标签: javajsoup

解决方案


推荐阅读