`
gcgmh
  • 浏览: 349379 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

httpclient htmlparser来查询手机号相关信息

阅读更多
httpclient  htmlparser来查询手机号相关信息
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("&nbsp;","")); 
        } 
    } 
    public static void main(String[] args) throws HttpException, IOException, ParserException { 
        getMobileInfor(getPostString("1380001"));//直接填写想要查询的手机号码 
    } 
 
} 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics