java - 使用 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());
解决方案
推荐阅读
- css - Pure-React-Carousel Flex 框对齐
- python - python / pandas如何将列表转换为单个单元格并以excel或cvs格式存储
- bash - 我可以在不使用 cat 的情况下将 shell 函数作为管道有条件地“消失”吗?
- time-complexity - 哪个更好:O(nm) 或 O(n log n)?
- javascript - Angular TypeScript:无法将数组分配给新数组
- node.js - findById 通过其 ID 显示产品详细信息的问题
- mysql - 根据情感 SQL 计算提及次数
- python - 如何在python中仅获取目录中与特定命名模式匹配的文件的名称,而忽略其他文件?
- python - 尝试打印与值对应的正确元素
- java - Java xml 解析 getElementById 返回 null