1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| String baseUrl = urlStr.substring(0, urlStr.indexOf("JobInfo.aspx")); URL url = null; try { url = new URL(urlStr); } catch (MalformedURLException e) { return null; } Document doc = null; try { doc = Jsoup.parse(url, 5000); } catch (IOException e) { return null; } Element jobDemand = doc.getElementById("jobDemand"); Element cmpyAddress1 = doc.getElementById("cmpyAddress1");
try { doc.getElementById("comemial").text().replace("邮箱:", ""); cmpyAddress1.getElementsByTag("a").get(0).text(); cmpyAddress1.getElementsByTag("a").get(0).attr("href"); cmpyAddress1.getElementsContainingOwnText("企业性质").get(0).getElementsByTag("span").get(1).text(); doc.getElementsByClass("tjobName").get(0).text(); doc.getElementsContainingOwnText("职位描述") .get(0) .nextElementSibling() .getElementsByTag("p") .get(0) .html(); } catch (Exception e) { return null; }
|