private PhoneResult mineAgentList(SearchResultItem item) { if (!isMinableAgentList(item)) return null; String html = getHtml(item.getRealUrl()); if (TextUtils.isEmpty(html) || !html.contains(item.getPhone())) return null; List<String> list = TextUtils.getList(html, "<div id='list_", "<div class=\"clear\">"); if (list != null && list.size() > 0) { for (String l : list) { if (l.contains(item.getPhone())) { String agent_href = TextUtils.getSubString(l, "<a href='", "'"); if (!TextUtils.isEmpty(agent_href) && agent_href.startsWith("/")) { String domain = TextUtils.getMatchGroup(PATTERN_AGENT_LIST, item.getRealUrl()); if (!TextUtils.isEmpty(domain)) { String aLink = domain + agent_href; return mineAgent(aLink); } } break; } } } return null; }
public static void main(String[] args) { SearchResultItem item = new SearchResultItem(); item.setRealUrl("http://esf.wuhan.fang.com/a/long878158?s=BingXML"); item.setPhone("18707151870"); item.setDomain("esf.wuhan.fang.com"); DomainFang domainFang = new DomainFang(); System.out.println(domainFang.mine(item)); }
@Override public PhoneResult mine(SearchResultItem item) { String url = item.getRealUrl(); if (isMinableAgent(item)) { return mineAgent(url); } else if (isMinableFang(item)) { return mineFang(item); } else if (isMinableAgentList(item)) { return mineAgentList(item); } return null; }
private boolean isMinableAgentList(SearchResultItem item) { return TextUtils.isMatchReg(PATTERN_AGENT_LIST, item.getRealUrl()); }
private boolean isMinableAgent(SearchResultItem item) { return isMinableAgent(item.getRealUrl()); }
@Override public boolean isMinableDomain(SearchResultItem item) { return TextUtils.isMatchReg(PATTERN_DOMAIN, item.getDomain()); }
private boolean isMinableFang(SearchResultItem item) { return TextUtils.isMatchReg(PATTERN_FANG, item.getRealUrl()); }