/// <summary> /// 微信支付实体爬取 /// </summary> /// <param name="docUrl"></param> /// <returns></returns> public string GetRequestModel2(string docUrl) { //docUrl = "https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_sl_api.php?chapter=9_1"; var resp = CrawlerHttpUtil.HttpGetRequest(docUrl, null, null, ""); var response_Str = CrawlerHttpUtil.GetResponseStreamToStr(resp); StringBuilder modelStr = new StringBuilder(); modelStr.Append(@" /// <summary> /// /// </summary> public class WechatPayV3Robot { "); try { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response_Str); HtmlNode rootNode = doc.DocumentNode; //var htmlNode = rootNode.SelectSingleNode("//table[contains(@class,'table')]//tbody"); var htmlNode = rootNode.SelectSingleNode("//table[contains(@class,'table')]"); if (htmlNode != null) { var nodes = htmlNode.SelectNodes("//tr"); HtmlAttribute att = null; foreach (var elem in nodes) { var tdnodes = elem.SelectNodes("./td"); if (tdnodes != null && tdnodes.Count == 6) { var description = tdnodes[5].InnerText.Replace("\r\n", " ").Replace(" ", ""); modelStr.Append($@" /// <summary> /// {tdnodes[0].InnerText} /// {description} /// </summary> public {GetType(tdnodes[3].InnerText)} {tdnodes[1].InnerText} {{ get; set; }} "); } else { } } } modelStr.Append("}"); return(modelStr.ToString()); } catch (Exception ex) { modelStr.Append("}"); return(modelStr.ToString()); } finally { } }
/// <summary> /// 特约商户进件接口爬取 转excel /// </summary> /// <param name="docUrl"></param> /// <returns></returns> public string exportRequest(string docUrl) { docUrl = "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_1.shtml"; var resp = CrawlerHttpUtil.HttpGetRequest(docUrl, null, null, ""); var response_Str = CrawlerHttpUtil.GetResponseStreamToStr(resp); StringBuilder modelStr = new StringBuilder(); List <ReqModel> req = new List <ReqModel>(); try { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response_Str); HtmlNode rootNode = doc.DocumentNode; var nodes = rootNode.SelectNodes("//div[@class='table-wrp']//tbody//tr"); if (nodes != null && nodes.Any()) { HtmlAttribute att = null; foreach (var elem in nodes) { var tdnodes = elem.SelectNodes("./td"); if (tdnodes != null && tdnodes.Count == 5) { req.Add(new ReqModel() { 称 = tdnodes[0].InnerText, 变量名 = tdnodes[1].InnerText, 类型 = tdnodes[2].InnerText, 必填 = tdnodes[3].InnerText, 说明 = tdnodes[4].InnerText, }); } else { } } } modelStr.Append("}"); var reqStr = JsonConvert.SerializeObject(req); return(modelStr.ToString()); } catch (Exception ex) { modelStr.Append("}"); return(modelStr.ToString()); } finally { } }
/// <summary> /// 特约商户进件接口爬取 /// </summary> /// <param name="docUrl"></param> /// <returns></returns> public string GetRequestModel1(string docUrl) { //docUrl = "https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/tool/applyment4sub/chapter3_1.shtml"; var resp = CrawlerHttpUtil.HttpGetRequest(docUrl, null, null, ""); var response_Str = CrawlerHttpUtil.GetResponseStreamToStr(resp); StringBuilder modelStr = new StringBuilder(); modelStr.Append(@" /// <summary> /// /// </summary> public class WechatPayV3Robot { "); try { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(response_Str); HtmlNode rootNode = doc.DocumentNode; var nodes = rootNode.SelectNodes("//div[@class='table-wrp']//tbody//tr"); if (nodes != null && nodes.Any()) { HtmlAttribute att = null; foreach (var elem in nodes) { var tdnodes = elem.SelectNodes("./td"); if (tdnodes != null && tdnodes.Count == 5) { var description = tdnodes[4].InnerText.Replace("\r\n", " ").Replace(" ", ""); //名称 = tdnodes[0].InnerText, // 变量名 = tdnodes[1].InnerText, // 类型 = tdnodes[2].InnerText, // 必填 = tdnodes[3].InnerText, // 说明 = tdnodes[4].InnerText, //"query\r\n \r\n 1、服务商自定义的唯一编号。\r\n 2、每个编号对应一个申请单,每个申请单审核通过后会生成一个微信支付商户号。 \r\n 3、若申请单被驳回,可填写相同的“业务申请编号”,即可覆盖修改原申请单信息。\r\n \r\n 示例值:APPLYMENT_00000000001 " modelStr.Append($@" /// <summary> /// {tdnodes[0].InnerText} /// {description.Replace("\t\t\t\t\t\t\t\t", "\r\n///")} /// </summary> public {GetType(tdnodes[2].InnerText)} {tdnodes[1].InnerText} {{ get; set; }} "); } else { } } } modelStr.Append("}"); return(modelStr.ToString()); } catch (Exception ex) { modelStr.Append("}"); return(modelStr.ToString()); } finally { } }