主界面框架:

package KnowAll;import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;public class KnowAllPanel extends JFrame{public KnowAllPanel() {showPanel();}JButton findIP = new JButton(" 查 询 I P ");JButton findMyIP = new JButton("查询自己的IP地址");JButton findID = new JButton("查询身份证号");JButton findNUMBER = new JButton("查询手机号码");JTextArea myIP = new JTextArea(2, 25);public void showPanel() {this.setTitle("百事通");this.setSize(410, 450);// 左长右高this.setLocation(500, 70);// 左水平又竖直this.setResizable(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);this.setLayout(new FlowLayout(FlowLayout.CENTER));//流式布局//添加图标并设置尺寸int width = 100;int height = 100;ImageIcon findIdNumber_img = new ImageIcon("img\\idcard.jpg");Image findIdNumber = findIdNumber_img.getImage();findIdNumber = findIdNumber.getScaledInstance(width, height, Image.SCALE_DEFAULT);findIdNumber_img.setImage(findIdNumber);JLabel id = new JLabel(findIdNumber_img,JLabel.CENTER);id.setSize(width, height);ImageIcon findIp_img = new ImageIcon("img\\ip.jpg");Image findIp = findIp_img.getImage();findIp = findIp.getScaledInstance(width, height, Image.SCALE_DEFAULT);findIp_img.setImage(findIp);JLabel ip = new JLabel(findIp_img,JLabel.CENTER);ip.setSize(width, height);ImageIcon findPhoneNumber_img = new ImageIcon("img\\phonenumber.jpg");Image findNumber = findPhoneNumber_img.getImage();findNumber = findNumber.getScaledInstance(width, height, Image.SCALE_DEFAULT);findPhoneNumber_img.setImage(findNumber);JLabel phoneNumber = new JLabel(findPhoneNumber_img,JLabel.CENTER);phoneNumber.setSize(width, height);//将图标、按钮添加到面板JPanel jp1 = new JPanel();jp1.add(ip);this.add(jp1);JPanel jp2 = new JPanel();jp2.add(id);this.add(jp2);JPanel jp3 = new JPanel();jp3.add(phoneNumber);this.add(jp3);JPanel jp4 = new JPanel();jp4.add(findIP);jp4.add(findID);jp4.add(findNUMBER);JPanel jp5 = new JPanel();jp5.add(findMyIP);this.add(jp4);this.add(jp5);JPanel jp6 = new JPanel();myIP.setEditable(false);jp6.add(myIP);this.add(jp6);//按钮添加监听findIP.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubsetVisible(false);FindipPanel panel = new FindipPanel();dispose();}});findID.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubsetVisible(false);FindidPanel panel = new FindidPanel();dispose();}});findNUMBER.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubsetVisible(false);FindPhoneNumberPanel panel = new FindPhoneNumberPanel();dispose();}});findMyIP.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubmyIP.setText("");myIP.setText(InquireIpFunction.getMyIpFromContent());}});}public static void main(String[] args) {KnowAllPanel panel = new KnowAllPanel();}
}

查询身份证号信息框架:

package KnowAll;import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;public class FindidPanel extends JFrame{public FindidPanel() {// TODO Auto-generated constructor stubshowPanel();}JTextField inputId = new JTextField(20);JButton inquire = new JButton("查询");JButton back = new JButton("返回");JTextArea resultText = new JTextArea(20, 30);public void showPanel() {this.setTitle("查询身份证号");this.setSize(410, 450);// 左长右高this.setLocation(500, 70);// 左水平又竖直this.setResizable(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);this.setLayout(new FlowLayout(FlowLayout.CENTER));//流式布局this.add(inputId);this.add(inquire);this.add(back);resultText.setEditable(false);this.add(resultText);back.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubsetVisible(false);KnowAllPanel panel = new KnowAllPanel();dispose();}});inquire.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubString idNumber = inputId.getText();String result = InquireIpFunction.getIdCardInfoFromURL(idNumber);resultText.setText(result);}});}public static void main(String[] args) {FindidPanel panel = new FindidPanel();}
}

查询IP地址信息框架:

package KnowAll;import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;public class FindipPanel extends JFrame {public FindipPanel() {// TODO Auto-generated constructor stubshowPanel();}JTextField inputIp = new JTextField(10);JButton inquire = new JButton("查询");JButton back = new JButton("返回");JTextArea resultText = new JTextArea(20, 30);public void showPanel() {this.setTitle("查询IP");this.setSize(410, 450);// 左长右高this.setLocation(500, 70);// 左水平又竖直this.setResizable(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);this.setLayout(new FlowLayout(FlowLayout.CENTER));// 流式布局this.add(inputIp);this.add(inquire);this.add(back);resultText.setEditable(false);this.add(resultText);back.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubsetVisible(false);KnowAllPanel panel = new KnowAllPanel();dispose();}});inquire.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {String ip = inputIp.getText();String result = InquireIpFunction.getIpInfoFromURL(ip);resultText.setText(result);}});}public static void main(String[] args) {FindipPanel panel = new FindipPanel();}
}

查找手机号码信息框架:

package KnowAll;import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;public class FindPhoneNumberPanel extends JFrame {public FindPhoneNumberPanel() {// TODO Auto-generated constructor stubshowPanel();}JTextField inputPhoneNumber = new JTextField(10);JButton inquire = new JButton("查询");JButton back = new JButton("返回");JTextArea resultText = new JTextArea(20, 30);public void showPanel() {this.setTitle("查询手机号码");this.setSize(410, 450);// 左长右高this.setLocation(500, 70);// 左水平又竖直this.setResizable(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setVisible(true);this.setLayout(new FlowLayout(FlowLayout.CENTER));// 流式布局this.add(inputPhoneNumber);this.add(inquire);this.add(back);resultText.setEditable(false);this.add(resultText);back.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubsetVisible(false);KnowAllPanel panel = new KnowAllPanel();dispose();}});inquire.addActionListener(new ActionListener() {@Overridepublic void actionPerformed(ActionEvent e) {// TODO Auto-generated method stubString phoneNumber = inputPhoneNumber.getText();String result = InquireIpFunction.getPhoneNumberInfoFromURL(phoneNumber);resultText.setText(result);}});}public static void main(String[] args) {FindPhoneNumberPanel panel = new FindPhoneNumberPanel();}
}

查询功能实现类:

package KnowAll;import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;public class InquireIpFunction {//查询自己的IPpublic static String getContentFromIp138() {try {URL url = new URL("http://2019.ip138.com/ic.asp");URLConnection conn = url.openConnection();conn.addRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36");Scanner scan = new Scanner(conn.getInputStream());StringBuffer sb = new StringBuffer();while(scan.hasNextLine()) {sb.append(scan.nextLine()).append("\r\n");}return sb.toString();} catch (MalformedURLException e1) {e1.printStackTrace();} catch (IOException e1) {e1.printStackTrace();}return null;}public static String getMyIpFromContent() {int Index = getContentFromIp138().indexOf("<center>");int endIndex = getContentFromIp138().indexOf("</center>");String result = getContentFromIp138().substring(Index+8, endIndex);return result;}//查询输入的IP地址的地理位置public static String getIpInfoFromURL(String ip) {StringBuffer content = new StringBuffer();try {Elements es = Jsoup.connect("http://ip138.com/ips138.asp?ip="+ip+"&action=2").get().getElementsByTag("li");if(es.size()>0) {for (int i = 0; i < es.size(); i++) {Element e = es.get(i);content.append(e.text()).append("\r\n");}}else {content.append("IP地址有误");}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}String result = content.toString();return result;}//查询身份证号码信息public static String getIdCardInfoFromURL(String idNumber) {StringBuffer content = new StringBuffer();try {Elements es = Jsoup.connect("http://qq.ip138.com/idsearch/index.asp?userid="+idNumber+"&action=idcard").get().getElementsByTag("td");if(es.size()>0) {for (int i = 0; i < es.size(); i++) {Element e = es.get(i);content.append(e.text()).append("\r\n");}}} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}String result = content.toString();return result;}//查询手机号码信息public static String getPhoneNumberInfoFromURL(String phoneNumber) {StringBuffer content = new StringBuffer();try {Elements es = Jsoup.connect("http://www.ip138.com:8080/search.asp?mobile="+phoneNumber+"&action=mobile").get().select(".TDC");if(es.size()>0) {for (int i = 3; i < es.size(); i++) {Element e = es.get(i);content.append(e.text()).append("\r\n");}}} catch (IOException e) {e.printStackTrace();}String result = content.toString().replace("测吉凶(新)", "").replace("更详细的..","");return result;}
}

集查询IP地址信息、查询手机号码信息、查询身份证号信息的一个小程序相关推荐

  1. 如何知道自己计算机的IP,怎么知道自己电脑的ip地址,手把手教你查询电脑ip地址...

    一般用户都是使用NDS自动配置,那么如果要指定一个固定的IP地址,并把IP绑定下,经常需要设置到本地IP地址,以方便管理.而在我们日常生活当中,也经常需要设置本地IP地址,比如我们需要使用路由器限制网 ...

  2. 使用Python批量查询ip地址的信息

    使用Python批量查询ip地址的信息 import requests from openpyxl import load_workbook from bs4 import BeautifulSoup ...

  3. 电脑查询ip地址的方法,第一种最为简单

    一般来说,每台电脑都会有固定的一个ip地址.部分电脑则是动态ip地址,每次连接网络时会自动分配.当我们需要查询ip地址的时候,该怎么操作呢?看完你就知道了. 更多系统教程尽在小白系统重装官网 系统:w ...

  4. linux指令查询ip地址

    linux指令查询ip地址 在黑窗口输入指令ifconfig: [root@baizhi ~]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:C ...

  5. 如何查询ip地址和端口号

    如何查询ip地址和端口号:开始菜单--运行--输入command--MS-DOS出来后输入ipconfig/all,其中IP Address就是你的地址.netstat -an(查看端口命令)... ...

  6. linux查看Windows的ip命令,在windows系统和linux系统中查询IP地址命令的不同

    在linux和windows系统上查询IP地址的命令是不一样的. 在linux中的命令行模式下,输入ifconfig即可查询到IP.而在windows系统下要查询IP地址需要先打开dos命令行,然后输 ...

  7. Python_身份证号信息查询

    # -*- coding: utf-8 -*- """ Created on Wed Sep 19 19:03:26 2018@author: LIU Zhendong ...

  8. python怎么查找代码位置查询_Python查询IP地址归属完整代码

    本文实例为大家分享了Python查询IP地址归属的具体代码,供大家参考,具体内容如下 #!/usr/bin/env python # -*- coding: utf-8 -*- #查找IP地址归属地 ...

  9. trie树java_【数据结构】Trie树的应用:查询IP地址的ISP(Java实现)

    查询IP地址的ISP 给定一个IP地址,如何查询其所属的ISP,如:中国移动(ChinaMobile),中国电信(ChinaTelecom),中国铁通(ChinaTietong)? 现在网上有ISP的 ...

  10. 在windows系统和linux系统中查询IP地址命令的不同

    在linux和windows系统上查询IP地址的命令是不一样的.         在linux中的命令行模式下,输入ifconfig即可查询到IP.而在windows系统下要查询IP地址需要先打开do ...

最新文章

  1. 查看进程-查看端口占用-杀进程
  2. 20、mysql中触发器的使用
  3. maven依赖最佳实践_Maven最佳实践
  4. java中process方法用处_Java中ProcessBuilder应用实例
  5. asp空间和php空间_免费ASP空间与免费PHP空间
  6. [六字真言]1.唵.遁入佛门之异常.md
  7. plsql如何显示表结构图_产品经理需了解的架构图/结构图知识
  8. C#中文件与文件夹相关的操作
  9. python把int转为str_python中int与str互转方法
  10. HCNA 实验指南(Ensp V350)
  11. health_parent的linux环境
  12. 使用TextPaint实现自由加粗字体:BoldTextView,支持中粗
  13. DevpTips【powerpoint】发现打不开,显示发现文件中的内容有问题。可尝试修复此演示文稿。
  14. SharePoint 2010管理中心创建网站集
  15. 计算机一级保存文件,计算机等级一级技巧:Word文档保存为PDF文件
  16. Python爬虫之Js逆向案例(6)-某道翻译
  17. ubuntu下ufw学习
  18. JPA(Java Persistence API )
  19. Echarts地图开发:geomap三级下钻带散点图的问题记录
  20. 2021-2027全球及中国家用无创睡眠呼吸机行业研究及十四五规划分析报告

热门文章

  1. 标准正态分布表(scipy.stats)
  2. vsftpd安装与配置
  3. 【Lingo】lingo使用
  4. 小规模纳税人季度申报流程指导
  5. 介绍一下小规模纳税人如何开具增值税专用发票的流程
  6. VsCode中文乱码问题
  7. rdkit 修改分子
  8. jquery dialog 打开的时候自动聚焦解决方法
  9. 带SN切换流程_贴片电阻生产工艺流程简介
  10. Speos — 光学产品设计仿真工具