protected void HttpApi() { //HtppZsjApi(); //return; string appKey = "AGIGZwdjA2BTZAY3V2dXYAM0W0gBNQM1XmEAMwY9BzoBZFJGB2cAZQJPDD5RawQ2DDlUQlBuURQLMF1rBzsMNQARBmAHYwNmU2sGN1dgVxMDRFs/AUoDMV5gADcGPwc/"; string appSecret = "ABEGZAdpAxZTHgZEV2BXZwNEWzsBPQNDXmUANQZMBzIBaFJHBxUAYgJJDEpRYgQ7DEpUP1BkURMLQV1tBzUMQw=="; //appKey = "AGIGZwdjA2BTHQY3V2RXYQM+Wz8BNAMyXmEAMwY9BzoBZ1JGBxUAagI+DD1RZQQzDE1UNlBpURQLMF1nBzwMMABpBmIHaQNkU20GMVdlVxcDNls7ATgDR15mADMGTgc4"; //appSecret = "AGIGZwdjA2BTaAY0V2xXYQNFWzABOwMwXmEAMwY9BzsBF1I6B2IAYgI6DD1RZQQ7DD1UNVBlUW4LMF0aB00MMAARBhIHZQMUU24GMldmV2ADMFtLAU8DNF5gADYGSQc4"; appKey = "AGIGZwdjA2BTHgY3V2NXYQNAWzABPgMxXmEAMwY9BzoBYFI1BxcAawI5DElRFwQ0DD5UQ1AfURELMF1nBzkMMQARBhIHFwNiUxoGNFcVVxcDQls4AUoDQV5iADMGNQdK"; appSecret = "AGIGZwdjA2BTaAY0V2xXYQNFWzABOwMwXmEAMwY9BzkBYVI6B2AAYAJPDDxRZARHDExUMVBvUWMLMF0aBzgMQwASBhEHZgMRU24GMVcQVxMDQltLAUkDPF5nADYGTwdI"; //string loginUrl = string.Format("https://10.200.67.197/ApiServe/GetToken");//?appKey={0}&appSecret={1}", appKey, appSecret); string loginUrl = string.Format("http://localhost:7434/ApiServe/GetToken"); //string dataUrl = "http://localhost:7434/AffordDevice/GetRooms?pageSize=5&pageIndex=1"; string dataUrl = "http://localhost:7434/AffordDevice/GetRooms"; NameValueCollection nvc = ToolWeb.GetNameValueCollection(new string[] { "appKey", "appSecret" }, new string[] { appKey, appSecret }); IWebHttpClient httpClient = new WebHttpClient(); string postData = nvc.ToQueryString(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; string html = httpClient.PostSync(new Uri(loginUrl), postData); string token = ToolWeb.GetHtmlByUrl(loginUrl, nvc); Dictionary <string, string> dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(token); //string json = httpClient.GetSync(new Uri(dataUrl), dict["token"]);// ToolWeb.GetHtmlByUrl(dataUrl);// //string dataUrl1 = "https://nszj2.szns.gov.cn/AffordDevice/GetPersons?pageSize=5&pageIndex=1"; //string personData = httpClient.GetSync(new Uri(dataUrl1), dict["token"]); //string dataUrl2 = "http://localhost:7434/AffordDevice/SetDoorAnomalyOpen"; string dataUrl2 = "http://localhost:7434/AffordDevice/SetDeviceAltitude"; //List<Face> faces = new List<Face>(); //Face face = new Face(); //face.CertType = 10; //face.PersonName = "张三"; //faces.Add(face); //Face face1 = new Face(); //face1.CertType = 10; //face1.PersonName = "李四"; //faces.Add(face1); //string postDatas = faces.ToDataJson(); //Dictionary<string, object> dicData = new Dictionary<string, object>(); //dicData.Add("data", postDatas); //string temp = "bsf\"sd\"hf"; //string jsonStr = "data:" + "zheshi"; string jsons = "[{\"IsFace\":true,\"PersonName\":\"郭滢\",\"RoomName\":\"3209\",\"EndTime\":\"2020-01-15 00:00:00.0\",\"LocateFloor\":\"32\",\"BuildingName\":\"1栋\",\"Sex\":\"女\",\"StartTime\":\"2019-01-16 00:00:00.0\",\"PhotoPath3\":\"\",\"CertType\":10,\"Mobile\":\"13148859655\",\"OpenPowers\":100,\"PhotoPath1\":\"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1599197027901&di=1e063142cad59d9b24f49bdb11443fe5&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fforum%2Fw%3D580%2Fsign%3D4534064588d4b31cf03c94b3b7d7276f%2F62ada5ec08fa513d294e71d83e6d55fbb3fbd9f6.jpg\",\"PhotoPath2\":\"\",\"RegisterTime\":\"2020-09-08 09:05:45.0\",\"DeviceType\":10,\"Desc\":\"\",\"RelationTypeOther\":\"申请人\",\"BiotopeName\":\"测试小区\",\"RegisterTypeOther\":\"租户\",\"RelationType\":1,\"IdCard\":\"120101198906260569\",\"RegisterType\":10,\"IsSffectivity\":true}]"; //jsons = "[{\"AnomalyOpens\":[{\"OpenType\":800,\"OpenCount\":2}],\"DeviceType\":20,\"Desc\":\"长期通过非刷脸开门\",\"BiotopeName\":\"测试小区\",\"RoomName\":\"3209\",\"EndTime\":\"2020-09-10\",\"AnomalyTime\":\"2020-09-10\",\"LocateFloor\":\"32\",\"OpenCount\":2,\"BuildingName\":\"1栋\",\"AnomalyNote\":\"长期通过非刷脸开门\",\"StartTime\":\"2020-08-11\"}]"; jsons = "[ {\"PersonName\": \"张三\",\"CertType\": 1,\"IdCard\": \" 42118119840********\",\"Mobile\": \"13255632245\",\"Sex\": \"男\",\"RelationType\": 1,\"BiotopeName\": \"蛇口人才公寓\",\"BuildingName\": \"B栋\",\"RoomName\": \"B1301\",\"LocateFloor\": \"16\",\"AltitudeDate\": \"2020-06-02\",\"ParabolicTime\": \"2023-06-01 14:32:14\",\"FloorTime\": \"2023-06-01 14:33:32\",\"FloorName\": \"椅子\",\"DeviceCodes\": \"SX001,SX002\", \"IsCasualties\":true,\"PersonNum\":4,\"FireNote\":\"2人重伤,2人轻伤,目前均以送往医院,无生命危险\",\"ImgPath1\": \"https://nszj2.szns.gov.cn/img/zs1.jpg\",\"ImgPath2\": \"https://nszj2.szns.gov.cn/img/zs2.jpg\",\"ImgPath3\": \"https://nszj2.szns.gov.cn/img/zs3.jpg\",\"ImgPath4\": \"https://nszj2.szns.gov.cn/img/zs4.jpg\",\"VideoPath1\": \"https://nszj2.szns.gov.cn/video/pw1.mp4\",\"VideoPath2\": \"https://nszj2.szns.gov.cn/video/pw2.mp4\",\"VideoPath3\": \"https://nszj2.szns.gov.cn/video/pw3.mp4\",\"VideoPath4\": \"https://nszj2.szns.gov.cn/video/pw4.mp4\",\"Explain\": \"该房号于2023-06-01 14:32:14从16楼抛下一把椅子,椅子落地坠毁,造成2人重伤,2人轻伤,目前均以送往医院,无生命危险\"}]"; string result = httpClient.PostSync(new Uri(dataUrl2), jsons, dict["token"]); string cookie = string.Empty; result = ToolHtml.GetHtmlByUrlPost(dataUrl2, jsons, dict["token"], Encoding.UTF8, ref cookie); }
protected override IList ExecuteCrawl(bool crawlAll) { string url = "https://zhaobiao.szairport.com/SZWI/portal/homeInformListJson.do"; IList list = new ArrayList(); //取得页码 int pageInt = 1; string html = string.Empty; string cookieStr = string.Empty; try { string post = string.Format("start={0}&limit={1}", 0, this.MaxCount); html = ToolHtml.GetHtmlByUrlPost(url, post, Encoding.UTF8, ref cookieStr); } catch (Exception ex) { } JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(html); Dictionary <string, object> tempDic = smsTypeJson["recordData"] as Dictionary <string, object>; if (tempDic == null) { return(list); } //string totalCount = tempDic["totalCount"].ToString(); //try //{ // pageInt = int.Parse(totalCount) / 20 + 1; //} //catch { } object[] objList = tempDic["records"] as object[]; foreach (object obj in objList) { string code = string.Empty, buildUnit = string.Empty, prjName = string.Empty, prjAddress = string.Empty, inviteCtx = string.Empty, inviteType = string.Empty, specType = string.Empty, beginDate = string.Empty, endDate = string.Empty, remark = string.Empty, inviteCon = string.Empty, InfoUrl = string.Empty, CreateTime = string.Empty, msgType = string.Empty, otherType = string.Empty, img = string.Empty, HtmlTxt = string.Empty; Dictionary <string, object> dic = obj as Dictionary <string, object>; prjName = Convert.ToString(dic["title"]); beginDate = Convert.ToString(dic["releaseTimeStr"]); string seqNo = Convert.ToString(dic["seqNo"]); InfoUrl = "http://zhaobiao.szairport.com/SZWI/portal/homeInformView.do?seqNo=" + seqNo; string htmldtl = string.Empty; try { htmldtl = this.ToolWebSite.GetHtmlByUrl(InfoUrl).GetJsString(); } catch { continue; } Parser parser = new Parser(new Lexer(htmldtl)); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "newsBox"))); if (dtlNode != null && dtlNode.Count > 0) { HtmlTxt = dtlNode.AsHtml(); inviteCtx = HtmlTxt.ToCtxString(); buildUnit = inviteCtx.GetBuildRegex(); prjAddress = inviteCtx.GetAddressRegex(); code = inviteCtx.GetCodeRegex().GetCodeDel(); if (code.Contains("__")) { code = ""; } specType = "其他"; msgType = "深圳宝安国际机场"; inviteType = ToolHtml.GetInviteTypes(prjName); InviteInfo info = ToolDb.GenInviteInfo("广东省", "深圳社会招标", "", string.Empty, code, prjName, prjAddress, buildUnit, beginDate, endDate, inviteCtx, remark, msgType, inviteType, specType, otherType, InfoUrl, HtmlTxt); list.Add(info); parser = new Parser(new Lexer(HtmlTxt)); NodeList aNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (aNode != null && aNode.Count > 0) { for (int a = 0; a < aNode.Count; a++) { ATag aTag = aNode[a] as ATag; if (aTag.IsAtagAttach()) { string fileUrl = string.Empty; if (aTag.Link.Contains("http")) { fileUrl = aTag.Link; } else { fileUrl = "http://zhaobiao.szairport.com/" + aTag.Link; } } } } if (!crawlAll && list.Count >= this.MaxCount) { return(list); } } } return(list); }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <NoticeInfo>(); int pageInt = 37; string html = string.Empty; string viewState = string.Empty; string eventValidation = string.Empty; string cookiestr = string.Empty; string url = "http://www.gsggzyjy.cn/ajax/Controls_InfoList,App_Web_rzplwhmc.ashx?_method=getCurrentData&_session=rw"; try { this.ToolWebSite.GetHtmlByUrl(this.SiteUrl, Encoding.UTF8, ref cookiestr); string post = "currentPage=1\r\nQuery="; html = ToolHtml.GetHtmlByUrlPost(url, post, Encoding.UTF8, ref cookiestr); } catch { return(null); } for (int i = 1; i <= pageInt; i++) { if (i > 1) { try { string post = "currentPage=" + i + "\r\nQuery="; html = ToolHtml.GetHtmlByUrlPost(url, post, Encoding.UTF8, ref cookiestr); } catch { continue; } } Parser parser = new Parser(new Lexer(html)); NodeList listNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("li")); if (listNode != null && listNode.Count > 0) { for (int j = 0; j < listNode.Count; j++) { string InfoTitle = string.Empty, InfoType = string.Empty, PublistTime = string.Empty, InfoCtx = string.Empty, InfoUrl = string.Empty, prjCode = string.Empty, buildUnit = string.Empty, htmlTxt = string.Empty, area = string.Empty; INode node = listNode[j]; ATag aTag = node.GetATag(); InfoTitle = aTag.GetAttribute("title"); InfoType = "控制价公示"; PublistTime = node.GetSpan().StringText; InfoUrl = "http://www.gsggzyjy.cn" + aTag.Link; string htmldtl = string.Empty; try { htmldtl = this.ToolWebSite.GetHtmlByUrl(InfoUrl).GetJsString(); } catch { continue; } parser = new Parser(new Lexer(htmldtl)); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "ContentPlaceHolder1_InfoHtml"))); if (dtlNode != null && dtlNode.Count > 0) { htmlTxt = dtlNode.AsHtml(); InfoCtx = htmlTxt.ToCtxString(); parser = new Parser(new Lexer(htmlTxt)); NodeList tableNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (tableNode != null && tableNode.Count > 0) { string ctx = string.Empty; TableTag table = tableNode[0] as TableTag; for (int r = 0; r < table.RowCount; r++) { for (int c = 0; c < table.Rows[r].ColumnCount; c++) { string temp = table.Rows[r].Columns[c].ToNodePlainString(); if ((c + 1) % 2 == 0) { ctx += temp.GetReplace(":,:") + "\r\n"; } else { ctx += temp.GetReplace(":,:") + ":"; } } } buildUnit = ctx.GetBuildRegex(); } NoticeInfo info = ToolDb.GenNoticeInfo("甘肃省", "甘肃省及地市", area, string.Empty, InfoTitle, InfoType, InfoCtx, PublistTime, string.Empty, "甘肃省公共资源交易中心", InfoUrl, prjCode, buildUnit, string.Empty, string.Empty, "交通运输工程", string.Empty, htmlTxt); parser = new Parser(new Lexer(htmlTxt)); NodeList aNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (aNode != null && aNode.Count > 0) { for (int k = 0; k < aNode.Count; k++) { ATag a = aNode[k].GetATag(); if (a.IsAtagAttach()) { string link = string.Empty; if (a.Link.ToLower().Contains("http")) { link = a.Link; } else { link = "http://www.gsggzyjy.cn/" + a.Link; } BaseAttach attach = ToolDb.GenBaseAttach(a.LinkText, info.Id, link); base.AttachList.Add(attach); } } } list.Add(info); if (!crawlAll && list.Count >= this.MaxCount) { return(list); } } } } } return(list); }