httpclient htmlparser来查询手机号相关信息
http://htmlparser.com.cn/post/20090816119.html
http://htmlparser.com.cn/post/20090816119.html
public class GetMobile {
/**
* @author rrong_m 51jsp.cn
* @throws IOException
* @throws HttpException
* @throws IOException
* @throws HttpException
* @throws ParserException
*/
public static String getPostString(String mobile) throws HttpException, IOException//发送数据51jsp.cn
{
HttpClient hc=new HttpClient();
PostMethod pm=new PostMethod("http://www.ip138.com:8080/search.asp");
hc.getParams().setContentCharset("gb2312");
pm.addParameter("mobile",mobile);
pm.addParameter("action","mobile");
hc.executeMethod(pm);
return pm.getResponseBodyAsString();
}
public static void getMobileInfor(String poststring) throws ParserException
{
Parser parser=new Parser(poststring);
NodeList nodelist=null;
NodeFilter filter=new HasAttributeFilter("class","tdc2");
nodelist=parser.extractAllNodesThatMatch(filter);
for(int i=0;i<nodelist.size();i++)
{
System.out.println(nodelist.elementAt(i).toPlainTextString().replace(" ",""));
}
}
public static void main(String[] args) throws HttpException, IOException, ParserException {
getMobileInfor(getPostString("1380001"));//直接填写想要查询的手机号码
}
}