ignore
This commit is contained in:
parent
dd718bbcfc
commit
1aaee7c03d
3
weixin4j-example/.gitignore
vendored
3
weixin4j-example/.gitignore
vendored
@ -30,3 +30,6 @@ target/*
|
||||
Thumbs.db
|
||||
/target/
|
||||
.DS_Store
|
||||
|
||||
# js ignore
|
||||
src/test/java/com/foxinmy/weixin4j/test/js/*
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
package com.foxinmy.weixin4j.test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ErrorBuilder {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Map<String, String> error = new TreeMap<String, String>();
|
||||
error.putAll(QyErrorBuilder.build());
|
||||
error.putAll(MpErrorBuilder.build());
|
||||
StringBuilder xml = new StringBuilder();
|
||||
xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
xml.append("<!-- 公众平台错误码:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433747234&token=&lang=zh_CN -->");
|
||||
xml.append("<!-- 企业号错误码:http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E -->");
|
||||
xml.append("<errors>");
|
||||
for (Entry<String, String> entry : error.entrySet()) {
|
||||
xml.append("<error>");
|
||||
xml.append("<code>").append(entry.getKey()).append("</code>");
|
||||
xml.append("<text>").append(entry.getValue()).append("</text>");
|
||||
xml.append("</error>");
|
||||
}
|
||||
xml.append("<!-- 商户平台错误码 -->");
|
||||
error = PayErrorBuilder.builder();
|
||||
for (Entry<String, String> entry : error.entrySet()) {
|
||||
xml.append("<error>");
|
||||
xml.append("<code>").append(entry.getKey()).append("</code>");
|
||||
xml.append("<text>").append(entry.getValue()).append("</text>");
|
||||
xml.append("</error>");
|
||||
}
|
||||
xml.append("</errors>");
|
||||
System.err.println("\n");
|
||||
System.err.println(xml.toString());
|
||||
}
|
||||
}
|
||||
@ -1,110 +0,0 @@
|
||||
package com.foxinmy.weixin4j.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import sun.org.mozilla.javascript.internal.NativeArray;
|
||||
import sun.org.mozilla.javascript.internal.NativeObject;
|
||||
|
||||
/**
|
||||
* 收集微信公众平台错误码
|
||||
*
|
||||
* @className MpErrorBuilder
|
||||
* @author jy
|
||||
* @date 2016年5月5日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class MpErrorBuilder {
|
||||
|
||||
private static final String HOME = "https://mp.weixin.qq.com/wiki";
|
||||
|
||||
private static final String RESOURCE = "https://mp.weixin.qq.com/wiki?action=doc&id=%s";
|
||||
|
||||
private static List<String> collectUrl() throws Exception {
|
||||
Document root = Jsoup.connect(HOME).get();
|
||||
List<String> resources = null;
|
||||
Elements eles = root.getElementById("resMenu").getElementsByTag("a");
|
||||
if (eles.isEmpty()) {
|
||||
Element ele = root.getElementsByTag("script").last();
|
||||
StringBuilder script = new StringBuilder();
|
||||
script.append("window = {};");
|
||||
script.append("seajs = {};");
|
||||
script.append("seajs.use = function(arg1,arg2){return window.cgiData.list};");
|
||||
script.append("wx_main = {};");
|
||||
script.append(ele.html());
|
||||
ScriptEngine engine = new ScriptEngineManager()
|
||||
.getEngineByName("javascript");
|
||||
NativeArray na = (NativeArray) ((NativeObject) engine.eval(script
|
||||
.toString())).get("list");
|
||||
resources = new ArrayList<String>();
|
||||
for (int i = 0; i < na.getLength(); i++) {
|
||||
recurrenceMenu(resources, (NativeObject) na.get(i));
|
||||
}
|
||||
} else {
|
||||
resources = new ArrayList<String>(eles.size());
|
||||
for (Element ele : eles) {
|
||||
resources.add(String.format(RESOURCE,
|
||||
ele.getElementsByAttribute("data-id")));
|
||||
}
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
|
||||
private static void recurrenceMenu(List<String> resources,
|
||||
NativeObject rootObject) {
|
||||
NativeArray children = (NativeArray) rootObject.get("children");
|
||||
if (children.getLength() == 0l) {
|
||||
resources.add(String.format(RESOURCE, rootObject.get("id")
|
||||
.toString()));
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
recurrenceMenu(resources, (NativeObject) children.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String, String> analyCode(String resource)
|
||||
throws Exception {
|
||||
Document root = Jsoup.connect(resource).get();
|
||||
Elements tables = root.getElementsByTag("table");
|
||||
Map<String, String> error = new HashMap<String, String>();
|
||||
for (Element table : tables) {
|
||||
Elements trs = table.getElementsByTag("tr");
|
||||
String text = trs.first().child(0).text().trim();
|
||||
if (text.equals("返回码") || text.equals("错误码")) {
|
||||
for (int i = 1; i < trs.size(); i++) {
|
||||
error.put(trs.get(i).child(0).text().trim(), trs.get(i)
|
||||
.child(1).text().trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
public static Map<String, String> build() throws Exception {
|
||||
System.err.println("0.开始收集URI资源...");
|
||||
List<String> resources = collectUrl();
|
||||
System.err.println("共收集到URI资源:" + resources.size());
|
||||
System.err.println("1.开始解析URI资源...");
|
||||
Map<String, String> error = new HashMap<String, String>();
|
||||
for (int i = 0; i < resources.size(); i++) {
|
||||
System.err
|
||||
.println("开始解析第" + (i + 1) + "个URI资源:" + resources.get(i));
|
||||
Map<String, String> result = analyCode(resources.get(i));
|
||||
System.err.println(resources.get(i) + ":" + result.size());
|
||||
error.putAll(result);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@ -1,129 +0,0 @@
|
||||
package com.foxinmy.weixin4j.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
/**
|
||||
* 手机微信商户平台错误码
|
||||
*
|
||||
* @className PayErrorBuilder
|
||||
* @author jy
|
||||
* @date 2016年5月5日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class PayErrorBuilder {
|
||||
|
||||
private static final String HOME = "https://pay.weixin.qq.com/wiki/doc/api/index.html";
|
||||
|
||||
private static final List<String> EXTRA_RESOURCES;
|
||||
static {
|
||||
EXTRA_RESOURCES = new ArrayList<String>();
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_3#");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_4");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/sp_coupon.php?chapter=12_5");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_7&index=6");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_5");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=16_6");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_1");
|
||||
EXTRA_RESOURCES
|
||||
.add("https://pay.weixin.qq.com/wiki/doc/api/external/declarecustom.php?chapter=18_2");
|
||||
}
|
||||
|
||||
private static List<String> collectUrl() throws Exception {
|
||||
Document root = Jsoup.connect(HOME).get();
|
||||
List<String> resources = new ArrayList<String>();
|
||||
Elements eles = root.getElementsByClass("guide-main");
|
||||
for (Element ele : eles) {
|
||||
for (Element li : ele.children()) {
|
||||
System.err.println(li.child(0).child(1).text() + "资源列表:");
|
||||
root = Jsoup.connect(li.child(0).absUrl("href")).get();
|
||||
Elements dls = root.getElementsByClass("menu").first()
|
||||
.getElementsByTag("dl");
|
||||
for (Element dl : dls) {
|
||||
if (dl.child(0).text().equalsIgnoreCase("api列表")) {
|
||||
for (int i = 1; i < dl.children().size(); i++) {
|
||||
System.err.println(dl.children().get(i).child(0)
|
||||
.text());
|
||||
resources.add(dl.children().get(i).child(0)
|
||||
.absUrl("href"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resources.addAll(EXTRA_RESOURCES);
|
||||
return resources;
|
||||
}
|
||||
|
||||
private static Map<String, String> analyCode(String resource)
|
||||
throws Exception {
|
||||
Document root = Jsoup.connect(resource).get();
|
||||
Elements eles = root.getElementsByClass("data-box");
|
||||
Map<String, String> error = new HashMap<String, String>();
|
||||
String text = "";
|
||||
StringBuilder desc = new StringBuilder();
|
||||
for (Element box : eles) {
|
||||
Elements trs = box.getElementsByTag("tr");
|
||||
if (trs.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
text = box.child(0).text().trim();
|
||||
boolean b1 = text.equals("错误码") || text.equals("返回码");
|
||||
text = trs.first().text().trim();
|
||||
boolean b2 = text.equals("错误码") || text.equals("返回码");
|
||||
if (b1 || b2) {
|
||||
for (int i = 1; i < trs.size(); i++) {
|
||||
desc.append(trs.get(i).child(1).text().trim());
|
||||
for (int j = 2; j < trs.get(i).children().size(); j++) {
|
||||
desc.append(",").append(
|
||||
trs.get(i).child(j).text().trim());
|
||||
}
|
||||
error.put(trs.get(i).child(0).text().trim(),
|
||||
desc.toString());
|
||||
desc.delete(0, desc.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
public static Map<String, String> builder() throws Exception {
|
||||
System.err.println("0.开始收集URI资源...");
|
||||
List<String> resources = collectUrl();
|
||||
System.err.println("共收集到URI资源:" + resources.size());
|
||||
System.err.println("1.开始解析URI资源...");
|
||||
Map<String, String> error = new TreeMap<String, String>();
|
||||
for (int i = 0; i < resources.size(); i++) {
|
||||
System.err
|
||||
.println("开始解析第" + (i + 1) + "个URI资源:" + resources.get(i));
|
||||
Map<String, String> result = analyCode(resources.get(i));
|
||||
System.err.println(resources.get(i) + ":" + result.size());
|
||||
error.putAll(result);
|
||||
}
|
||||
System.err.println("共收集到状态码:" + error.size());
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
package com.foxinmy.weixin4j.test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
/**
|
||||
* 收集微信企业号错误码
|
||||
*
|
||||
* @className QyErrorBuilder
|
||||
* @author jy
|
||||
* @date 2016年5月5日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class QyErrorBuilder {
|
||||
|
||||
private static final String HOME = "http://qydev.weixin.qq.com/wiki/index.php?title=%E5%85%A8%E5%B1%80%E8%BF%94%E5%9B%9E%E7%A0%81%E8%AF%B4%E6%98%8E";
|
||||
|
||||
private static Map<String, String> analyCode() throws Exception {
|
||||
Document root = Jsoup.connect(HOME).get();
|
||||
Elements trs = root.getElementsByTag("tr");
|
||||
Map<String, String> error = new TreeMap<String, String>();
|
||||
for (int i = 1; i < trs.size(); i++) {
|
||||
error.put(trs.get(i).child(0).text().trim(), trs.get(i).child(1)
|
||||
.text().trim());
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
public static Map<String, String> build() throws Exception {
|
||||
System.err.println("开始解析URI资源:" + HOME);
|
||||
Map<String, String> error = analyCode();
|
||||
System.err.println("共收集到状态码:" + error.size());
|
||||
return error;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user