首页 企业工商信息 企业工商信息示例代码 企业工商信息查询[Java]

企业工商信息查询示例代码[Java]

作者:xiezhongpian 阅读数:2290 上传时间:2017-05-09

企业工商信息查询

package api.jisuapi.enterprise;

import java.net.URLEncoder;

import api.util.HttpUtil;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class Query {
	public static final String APPKEY = "your_appkey_here";// 你的appkey
	public static final String URL = "https://api.jisuapi.com/enterprise/query";
	public static final String company = "杭州网尚科技有限公司";// utf-8 以下三项任选一个
	public static final String creditno = "1";
	public static final String pagenum = "20";

	public static void Get() throws Exception {
		String result = null;
		String url = URL + "?appkey=" + APPKEY + "&company=" + URLEncoder.encode(company, "utf-8");

		try {
			result = HttpUtil.sendGet(url, "utf-8");
			JSONObject json = JSONObject.fromObject(result);
			if (json.getInt("status") != 0) {
				System.out.println(json.getString("msg"));
			} else {
				JSONObject resultarr = json.optJSONObject("result");
				JSONObject basic = resultarr.optJSONObject("basic");
				String name = basic.getString("name");
				String type = basic.getString("type");
				String regcapital = basic.getString("regcapital");
				String scope = basic.getString("scope");
				String startdate = basic.getString("startdate");
				String enddate = basic.getString("enddate");
				String regorgan = basic.getString("regorgan");
				String legalperson = basic.getString("legalperson");
				String approvaldate = basic.getString("approvaldate");
				String regdate = basic.getString("regdate");
				String canceldate = basic.getString("canceldate");
				String status = basic.getString("status");
				String orgno = basic.getString("orgno");
				String creditno = basic.getString("creditno");
				String province = basic.getString("province");
				String regno = basic.getString("regno");
				String regaddress = basic.getString("regaddress");
				System.out.println(name + " " + type + " " + regcapital + " " + scope + " " + startdate + " " + enddate
						+ " " + regorgan + " " + legalperson + " " + approvaldate + " " + regdate + " " + canceldate
						+ " " + status + " " + orgno + " " + creditno + " " + province + " " + regno + " "
						+ regaddress);
				if (resultarr.opt("keyperson") != null) {
					JSONArray keyperson = resultarr.optJSONArray("keyperson");
					for (int i = 0; i < keyperson.size(); i++) {
						JSONObject obj = (JSONObject) keyperson.opt(i);
						String name1 = obj.getString("name");
						String position = obj.getString("position");
						System.out.println(name1 + " " + position);
					}
				}
				if (resultarr.opt("changerecord") != null) {
					JSONArray changerecord = resultarr.optJSONArray("changerecord");
					for (int i = 0; i < changerecord.size(); i++) {
						JSONObject obj = (JSONObject) changerecord.opt(i);
						String name1 = obj.getString("name");
						String beforecontent = obj.getString("beforecontent");
						String aftercontent = obj.getString("aftercontent");
						String changedate = obj.getString("changedate");
						System.out.println(name1 + " " + beforecontent + " " + aftercontent + " " + changedate);
					}
				}
				if (resultarr.opt("shareholder") != null) {
					JSONArray shareholder = resultarr.optJSONArray("shareholder");
					for (int i = 0; i < shareholder.size(); i++) {
						JSONObject obj = (JSONObject) shareholder.opt(i);
						String name1 = obj.getString("name");
						String type1 = obj.getString("type");
						String cardtype = obj.getString("cardtype");
						String cardno = obj.getString("cardno");
						String subcapital = obj.getString("subcapital");
						String paidcapital = obj.getString("paidcapital");
						System.out.println(name1 + " " + type1 + " " + cardtype + " " + cardno + " " + subcapital + " "
								+ paidcapital);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}