public BKBook getBKBook(String url) { String content = hc.getAsString(url); Document document = Jsoup.parse(content); BKBook bb = new BKBook(); bb.title = url; bb.dxid = StringUtils.substringBetween(url, "dxNumber=", "&"); bb.title = BaokuDownload.normalize(document.select("#topsw").val()); bb.status = 0; return bb; }
public String getBaokuUrl(BKBook bb) { String content = hc.getAsString(bb.url); if (content.contains("我们检测到您的操作可能有异常")) throw new IllegalStateException("我们检测到您的操作可能有异常 " + bb.url); for (Element e : Jsoup.parse(content, bb.url).select(".btn a")) { if (e.text().equals("包库全文阅读")) { return e.absUrl("href"); } } return null; }
@Test public void test111() { HC hc = HCs.makeHC(); String cookie = "ASP.NET_SessionId=qaei0j344l2ax3nki0cqv455;"; for (int bsid = 370000; bsid <= 371000; ++bsid) { String content = hc.asString( Req.get( "http://electsys.sjtu.edu.cn/edu/lesson/viewLessonArrangeDetail2.aspx?bsid=" + bsid) .cookie(cookie)); Document doc = Jsoup.parse(content); Elements tds = doc.select("#LessonArrangeDetail1_dataListKc table td"); if (tds.size() > 2) { String kh = tds.get(2).text(); if (kh.contains("SE") && kh.contains("2015-2016-2")) { System.out.println(tds.get(1).text() + " " + bsid); } } } }