MVN:
<dependency>
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160810</version>
</dependency>
程序:
{
Map<String, String> map = new HashMap<>();
System.out.println("urlLink:" + urlLink);
Document document = Jsoup.connect(urlLink).timeout(10000).get();
// System.out.println(" 获取资源结束,开始解析。 document: "+document);
if (document != null) {
System.out.println("解析开始");
Elements elements = document.select(".ad-title");
for (Element e1 : elements) {
String link = e1.attr("href").trim();
links.add(link);
}
Elements es2 = document.select(".salary");
for (Element e3 : es2) {
String sa1 = e3.text().trim();
if (sa1.length() < 5) {
sa1 = "3000-4000";
}
String sa2 = sa1.substring(0, 4);
salarys.add(sa2);
}
Elements es3 = document.select(".table-view-cap");
for (Element e4 : es3) {
String a1 = e4.text().trim();
String[] a2 = a1.split("/");
String c1 = a2[0].trim();
String a3 = a2[1].trim();
areaName.add(a3);
contacts.add(c1);
}
for (int i = 0; i < links.size(); i++) {
getFullDetails(links.get(i), salarys.get(i), areaName.get(i), contacts.get(i));
}
} else {
System.out.println("document is null");
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/38483.html