当前位置:   article > 正文

Java---身份证号查询, 手机号查询_java 根据用户userid查询用户手机号

java 根据用户userid查询用户手机号

 身份证号查询

  1. import org.jsoup.Jsoup;
  2. import java.io.IOException;
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5. public class Id {
  6. public static void main(String[] args) {
  7. String id ="******************";
  8. String u = "https://qq.ip138.com/idsearch/index.asp?userid=" +id+"&action=idcard";
  9. System.out.println(id);
  10. try {
  11. String t = Jsoup.connect(u).get().toString();
  12. Pattern p = Pattern.compile("[\\u4e00-\\u9fa5\\s]+?<br>");
  13. Pattern p2 = Pattern.compile("男|女");
  14. Matcher m2 = p2.matcher(t);
  15. m2.find();
  16. System.out.println(m2.group());
  17. Pattern p3 = Pattern.compile("\\d{4}年\\d{2}月\\d{2}日");
  18. Matcher m3 = p3.matcher(t);
  19. m3.find();
  20. System.out.println(m3.group());
  21. Matcher m = p.matcher(t);
  22. while (m.find()){
  23. System.out.println(m.group().replace("<br>","").replace("",""));
  24. System.out.println(m.group().replaceAll("[^\\u4e00-\\u9fa5]",""));
  25. }
  26. } catch (IllegalStateException e) {
  27. System.out.println("未找到");
  28. throw new RuntimeException(e);
  29. }catch (IOException e){
  30. System.out.println("网络异常");
  31. }catch (Exception e){
  32. System.out.println("未知错误异常");
  33. }
  34. }
  35. }

手机号查询

  1. package cn;
  2. import org.jsoup.Jsoup;
  3. import java.io.IOException;
  4. import java.util.Scanner;
  5. import java.util.regex.Matcher;
  6. import java.util.regex.Pattern;
  7. public class Tell {
  8. public static void main(String[] args) throws IOException {
  9. Scanner sc = new Scanner(System.in);
  10. System.out.print("请输入手机号");
  11. String tell = sc.nextLine();
  12. String u = String.format("https://ip138.com/mobile.asp?mobile=%s&action=mobile",tell);
  13. String html = Jsoup.connect(u).get().toString();
  14. Pattern pattern = Pattern.compile("<td><span>(.*)</span></td>");
  15. Matcher matcher = pattern.matcher(html);
  16. while (matcher.find()){
  17. System.out.println(matcher.group(1).replace("&nbsp;",""));
  18. }
  19. }
  20. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/691003
推荐阅读
相关标签
  

闽ICP备14008679号