java程序代码实现手机号码归属地查询,求源码?
1个回答
展开全部
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class Test {
public static void main(String[] args) throws IOException {
String mobile = "手机号码";
String url = "http://www.ip138.com:8080/search.asp?action=mobile&mobile=%s";
url = String.format(url, mobile);
Document doc = Jsoup.connect(url).get();
Elements els = doc.getElementsByClass("tdc2");
System.out.println("归属地:" + els.get(1).text());
System.out.println("类型:" + els.get(2).text());
System.out.println("区号:" + els.get(3).text());
System.out.println("邮编:" + els.get(4).text().substring(0, 6));
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询