using BrightIdeasSoftware; using DotNet4.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using ryCommon; using ryCommonDb; using ryControls; using ryProcessManager.hezuo; using ScintillaNETV2; using 开发辅助工具.Controls; using 开发辅助工具.Tools; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Design; using System.IO; using System.Linq; using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using System.Xml; using WeifenLuo.WinFormsUI.Docking; using 开发辅助工具.Manager; using System.Xml.Linq; using SuperDesign.Manager; using SuperDesign.Tools; using ScintillaNETV2.Highlight; using System.Runtime.InteropServices; using WinShell; namespace 开发辅助工具.Tools { public partial class FrmWebGet : DockContent { public FrmWebGet() { InitializeComponent(); LoadPram(); tabControl2.SelectedTab = tabPage12; OlvUrl.AspectGetter = delegate (object x) { return ((UrlInfo)x)?.Url; }; OlvUrl.Renderer = new UrlRenderer(); OlvName.AspectGetter = delegate (object x) { var item = (UrlInfo)x; if (item==null || item.Des.Length == 0) { return item==null?"":item.Name; } else { return "【"+item.Des+"】"+ item.Name; } }; //OlvUrl.Renderer = CreateDescribedTaskRenderer(); objectListView2.FormatRow += ObjectListView2_FormatRow; } class UrlRenderer : BaseRenderer { public UrlRenderer() { UseGdiTextRendering = false; } // // 摘要: // Draw the flags // // 参数: // g: // // r: public override void Render(Graphics g, Rectangle r) { DrawBackground(g, r); if (!(base.Aspect is IConvertible convertible)) { return; } r = ApplyCellPadding(r); if (base.RowObject is UrlInfo item1) { var start_x = 0; if(item1.Icon!=null) { start_x += DrawImage2(g, r, start_x,new Bitmap(item1.Icon)); } start_x += DrawText2(g, r, start_x,item1.Url); } } } private DescribedTaskRenderer CreateDescribedTaskRenderer() { // Let's create an appropriately configured renderer. DescribedTaskRenderer renderer = new DescribedTaskRenderer { // Give the renderer its own collection of images. // If this isn't set, the renderer will use the SmallImageList from the ObjectListView. // (this is standard Renderer behaviour, not specific to DescribedTaskRenderer). // Tell the renderer which property holds the text to be used as a description DescriptionAspectName = "Name", UseCustomCheckboxImages = false, // Change the formatting slightly TitleFont = new Font("宋体", 9, FontStyle.Regular), DescriptionFont = new Font("宋体", 9), DescriptionColor = Color.Gray, TopSpace = 2, //renderer.ImageTextSpace = 8; TitleDescriptionSpace = 2, // Use older Gdi renderering, since most people think the text looks clearer UseGdiTextRendering = true }; // If you like colours other than black and grey, you could uncomment these // renderer.TitleColor = Color.DarkBlue; // renderer.DescriptionColor = Color.CornflowerBlue; return renderer; } private void ObjectListView2_FormatRow(object sender, BrightIdeasSoftware.FormatRowEventArgs e) { var item = (UrlInfo)e.Model; if (item!=null && item.Fav) { e.Item.ForeColor = Color.Blue; } else { e.Item.ForeColor = Color.Black; } } private void LoadPram() { CbbContentType.SelectedIndex = 0; CbbEncoding.SelectedIndex = 0; CbbTimeout.SelectedIndex = CbbTimeout.Items.Count-2; CbbWriteTimeout.SelectedIndex = CbbWriteTimeout.Items.Count - 2; CbbUserAgent.Items.AddRange(new ComboPopupItem[]{ new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "Edge浏览器", ValueStr1 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "Chrome浏览器", ValueStr1 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "Firefox浏览器", ValueStr1 = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "Opera浏览器", ValueStr1 = "Opera/9.27 (Windows NT 5.2; U; zh-cn)" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "IE7浏览器", ValueStr1 = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT6.0)" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "IE9浏览器", ValueStr1 = "Mozilla/5.0(compatible;MSIE9.0;WindowsNT6.1;Trident/5.0;" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "QQ浏览器极速模式", ValueStr1 = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.6776.400 QQBrowser/10.3.2601.400" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.windows,Text = "360浏览器极速模式", ValueStr1 = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.安卓, Text = "华为浏览器安卓手机版", ValueStr1 = "Mozilla/5.0 (Linux; Android 12; HarmonyOS; NAM-AL00; HMSCore 6.14.0.302) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.196 HuaweiBrowser/15.0.7.301 Mobile Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.安卓,Text = "UC浏览器安卓手机版", ValueStr1 = "Mozilla/5.0 (Linux; U; Android 12; zh-CN; NAM-AL00 Build/HUAWEINAM-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/100.0.4896.58 UCBrowser/16.4.2.1293 Mobile Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.安卓,Text = "QQ浏览器安卓手机版", ValueStr1 = "Mozilla/5.0 (Linux; U; Android 8.1.0; zh-cn; BLA-AL00 Build/HUAWEIBLA-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 MQQBrowser/8.9 Mobile Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.安卓,Text = "360浏览器安卓手机版", ValueStr1 = "Mozilla/5.0 (Linux; Android 12; NAM-AL00 Build/HUAWEINAM-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/81.0.4044.145 Mobile Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.安卓,Text = "安卓", ValueStr1 = "Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03S) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.鸿蒙os, Text = "Harmony OS NEXT 华为浏览器", ValueStr1 = "Mozilla/5.0 (Phone; OpenHarmony 5.0)AppleWebKit/537.36 (KHTML, like Gecko)Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile HuaweiBrowser/5.0.3.351" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.鸿蒙os, Text = "Harmony OS NEXT UC浏览器", ValueStr1 = "Mozilla/5.0 (Phone; OpenHarmony 5.0)AppleWebKit/537.36 (KHTML, like Gecko)Chrome/114.0.0.0 ArkWeb/4.1.6.1 UCBrowser/1.1.6.0 Mobile Safari/537.36" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.鸿蒙os, Text = "Harmony OS NEXT QQ浏览器", ValueStr1 = "Mozilla/5.0 (Phone; Android 14;OpenHarmony 5.0) AppleWebKit/537.36(KHTML, like Gecko) Version/4.0 Chrome/ 114.0.0.0 ArkWeb/4.1.6.1 Mobile Safari/537.36qbyouthfynohead/15.0" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.鸿蒙os, Text = "Harmony OS NEXT 360浏览器", ValueStr1 = "Mozilla/5.0 (Phone; OpenHarmony 5.0;HarmonyOS 5.0) AppleWebKit/537.36(KHTML,like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile Browser/harmony360Browser/1.0.0" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.微信,Text = "微信", ValueStr1 = "Mozilla/5.0 (Linux; U; Android 4.1.2; zh-cn; GT-I9300 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 MicroMessenger/5.2.380" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.iphone, Text = "iPhone", ValueStr1 = "Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1C28 Safari/419.3" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.iphone, Text = "Safari Mac浏览器", ValueStr1 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.6 Safari/605.1.15" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.iphone, Text = "Edge浏览器 Mac版", ValueStr1 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0" }, new ComboPopupItem() {Image=SuperDesign.Properties.Resources.iphone, Text = "Chrome浏览器 Mac版", ValueStr1 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" }, }); CbbUserAgent.SelectedIndex = 0; TxtPost.AddSeparatorMenu(); TxtPost.AddMenu("将选定项进行Url编码(UTF8)", "").Click += new EventHandler((object sender2, EventArgs e2) => { RyWeb.QuickWeb web = new RyWeb.QuickWeb(); TxtPost.SelectedText = web.UrlEncode(TxtPost.SelectedText, Encoding.UTF8); }); TxtPost.AddMenu("将选定项进行Url编码(GB2312)", "").Click += new EventHandler((object sender2, EventArgs e2) => { RyWeb.QuickWeb web = new RyWeb.QuickWeb(); TxtPost.SelectedText = web.UrlEncode(TxtPost.SelectedText, Encoding.GetEncoding("GB2312")); }); TxtPost.AddSeparatorMenu(); TxtPost.AddMenu("将选定项进行Url解码(UTF8)", "").Click += new EventHandler((object sender2, EventArgs e2) => { TxtPost.SelectedText = RyWeb.WebDecode.UrlDecode(TxtPost.SelectedText, Encoding.UTF8); }); TxtPost.AddMenu("将选定项进行Url解码(GB2312)", "").Click += new EventHandler((object sender2, EventArgs e2) => { TxtPost.SelectedText = RyWeb.WebDecode.UrlDecode(TxtPost.SelectedText, Encoding.GetEncoding("GB2312")); }); TxtPost.AddSeparatorMenu(); TxtPost.AddMenu("查询选定项对应的时间", "unixtime").Click += new EventHandler((object sender2, EventArgs e2) => { MessageBox.Show("当前选中的时间是:" + RyDate.UnixTimeToDateTime(TxtPost.SelectedText).ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }); TxtPost.AddMenu("插入时间戳", "").Click += new EventHandler((object sender2, EventArgs e2) => { 开发辅助工具.Controls.FrmInsertUnixTime frm = new 开发辅助工具.Controls.FrmInsertUnixTime { Icon = Icon }; var text = TxtPost.SelectedText; if(text.Length>4 && text.IsInt()) { frm.dateTimePickerEX1.Value = RyDate.UnixTimeToDateTime(text); } if (frm.ShowDialog()==DialogResult.OK) { TxtPost.SelectedText = RyDate.DateTimeToUnixTime(frm.dateTimePickerEX1.Value).ToString(); } // MessageBox.Show("当前选中的时间是:" + RyDate.UnixTimeToDateTime(TxtPost.SelectedText).ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }); TxtPost.OnMenuOpening += TxtPost_OnMenuOpening; } private void TxtPost_OnMenuOpening(object sender, CancelEventArgs e) { var item= TxtPost.GetMenuItem("unixtime"); if(item!=null) { var text = TxtPost.SelectedText; item.Visible = text.IsInt() && text.Length>4; } } private bool IsExit = false; private bool IsRunning = false; Thread th; private void BtnRunHtml_Click(object sender, EventArgs e) { objectListView2.Visible = false; if (IsRunning) { IsExit = true; BtnRunHtml.Text = "停止中"; ; if (th!=null && th.IsAlive) { th.Abort(); } return; } IsExit = false; IsRunning = true; BtnRunHtml.Text = "停止执行"; ; #region 将当前设置赋值到查询 this.RichHtml.Text = "正在获取数据..."; highlightEditor1.Text="正在获取数据..."; this.RichCookie.Text = ""; RichHeader.Text = ""; RichStatus.Text = ""; extendedWebBrowser1.LoadStrings(""); if (TxtUrl.Text.IndexOfEx("//") == 0) { TxtUrl.Text = "http:" + TxtUrl.Text; } else if (TxtUrl.Text.IndexOfEx("://") == 0) { TxtUrl.Text = "http" + TxtUrl.Text; } else if (TxtUrl.Text.IndexOfEx("http") != 0) { TxtUrl.Text = "http://" + TxtUrl.Text.TrimStart('/'); } string str = GetMethod(); var PostData = this.TxtPost.Text.Trim(); if (str == "head") { PostData = ""; } if (CbbContentType.Text== "application/json") { try { JObject jo = (JObject)JsonConvert.DeserializeObject(PostData); PostData = Newtonsoft.Json.JsonConvert.SerializeObject(jo, new Newtonsoft.Json.JsonSerializerSettings() { StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeNonAscii }); } catch { } } HttpItem item = new HttpItem { URL = TxtUrl.Text.Trim(), Method = str, Cookie = this.TxtCookie.Text.Trim(), Referer = this.CbbReferer.Text.Trim(), Postdata = PostData, Timeout = this.CbbTimeout.Text.Replace("秒", string.Empty).Trim().ToInt() * 0x3e8, ReadWriteTimeout = this.CbbWriteTimeout.Text.Replace("秒", string.Empty).Trim().ToInt() * 0x3e8, UserAgent = this.CbbUserAgent.Text, ContentType = this.CbbContentType.Text, Allowautoredirect = this.ChkJump.Checked, ProtocolVersion = System.Net.HttpVersion.Version11, ResultType = ChkGetPic.Checked ? ResultType.Byte : ResultType.String, }; if (TxtInputHeader.Text.Length > 0) { try { string[] item_header = TxtInputHeader.Text.Replace("\r", "").Split('\n'); for (int i = 0; i < item_header.Length; i++) { var split = item_header[i].Split(':'); if(split.Length==2) { if (split[0].ToLower()== "accept") { item.Accept= split[1]; continue; } else if (split[0].ToLower() == "content-type") { item.ContentType = split[1]; continue; } } item.Header.Add(item_header[i]); //int iPos = item_header[i].LastIndexOf(":"); //if (iPos > 0) //{ // var header_name = item_header[i].Substring(0, iPos); // var header_value = item_header[i].Substring(iPos + 1); // item.Header.Add(header_name, header_value); //} } } catch (Exception exception) { this.RichHtml.Text = exception.Message; highlightEditor1.Text = ""; tabControl2.SelectedIndex = 0; BtnRunHtml.Text = "执行"; IsRunning = false; return; } } if (CbbUserAgent.SelectedIndex != -1) { if (CbbUserAgent.SelectedItem is ComboPopupItem info) { item.UserAgent = info.ValueStr1; } } if (!string.IsNullOrEmpty(this.CbbIp.Text.Trim())) { item.ProxyIp = this.CbbIp.Text.Trim(); } if (!this.CbbEncoding.Text.Contains("自动")) { item.Encoding = Encoding.GetEncoding(this.CbbEncoding.Text.Trim()); } #endregion if (th != null && th.IsAlive) { th.Abort(); } if(RbHead.Checked) { tabControl2.SelectedTab = tabPage6; } th = new Thread(Start); th.Start(); void Start() { try { var http = new HttpHelper(); DateTime dt = DateTime.Now; var result = http.GetHtml(item); DateTime dt_end = DateTime.Now; if (result.StatusCode == System.Net.HttpStatusCode.OK) { Uri uri = null; var api_url = ""; string api_name = ""; try { uri = new Uri(item.URL); var host = uri.Host.ToLower(); if(!System.IO.File.Exists(Application.StartupPath+ "\\SysDb\\webicons\\"+host+".png") && !System.IO.File.Exists(Application.StartupPath + "\\UserDb\\webicons\\" + host + ".ico")) { var img = RyImage.LoadPic(uri.Scheme+"://"+uri.Host+ "/favicon.ico"); if(img!=null) { img.Save(Application.StartupPath + "\\UserDb\\webicons\\" + host + ".ico"); } } if (host.IndexOfEx("www.87g") == 0 || host.IndexOfEx("www.3h3") == 0 || host.IndexOfEx("www.downxia") == 0 || host.IndexOfEx("www.downbank") == 0 || host.IndexOfEx("www.downxing") == 0 || host.IndexOfEx("downwn.com") == 0) { if (str=="get") { api_url = "" + uri.AbsolutePath; } else { api_url = "" + uri.PathAndQuery; } var urlparam = RyWeb.WebDecode.UrlToData(uri.OriginalString); api_name = urlparam.Get("a"); if (api_name.Length == 0) { api_name = urlparam.Get("api"); } } else { if (str == "get") { api_url = uri.Scheme + "://" + uri.Host + (uri.Port == 80 ? "" : (":" + uri.Port)) + uri.AbsolutePath; } else { api_url = uri.OriginalString; } } Dictionary dict_urlpost = new Dictionary(); if (!item.Postdata.StartsWith("{")) { var post = RyWeb.WebDecode.UrlToData(str == "get" ? uri.OriginalString : ("f?" + item.Postdata)); if (post.Item2 != null) { dict_urlpost = post.Item2.ToDictionary(item2 => item2.Key, item2 => item2.Value); } } if (dict_urlpost.Count > 0) { IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { bool is_update = false; RyQuickSQL mySQL = new RyQuickSQL("api"); mySQL.AddField("Url", api_url); DataSet ds = db.ReadData("select * from api where Url=@Url", mySQL); var json_post = ""; if (ds.HaveData()) { var row = ds.GetFirstRowData(); json_post = row["Postdata"].ToString(); is_update = true; mySQL.AddField("ClickCount", row["ClickCount"].ToInt() + 1);//点击次数 } else { mySQL.AddField("Name", ""); mySQL.AddField("APIName", api_name); mySQL.AddField("addTime", DateTime.Now); mySQL.AddField("AddUser", "robot"); } mySQL.AddField("editTime", DateTime.Now); JObject jo; if (json_post.Length == 0) { jo = new JObject(); } else { jo = JObject.Parse(json_post); } Dictionary dict_post = new Dictionary(); if (jo.ContainsKey("list")) { JArray jarr = JArray.Parse(jo["list"].ToString()); for (int i = 0; i < jarr.Count; i++) { var item_jarr = jarr[i]; var param_name = item_jarr["paramname"].ToString(); dict_post[param_name] = new PostInfo() { Title = item_jarr["title"].ToString(), ParamName = param_name, Desc = item_jarr["desc"].ToString(), }; } foreach (var item2 in dict_urlpost) { if (!dict_post.ContainsKey(item2.Key)) { JObject jo_item = new JObject { { "paramname", item2.Key }, { "title", APIManager.GetParamTitle(item2.Key) }, { "paramvalue", item2.Value }, { "desc", "" } }; jarr.Add(jo_item); } } jo["list"] = jarr; } else { JArray jarr_new = new JArray(); foreach (var item2 in dict_urlpost) { JObject jo_item = new JObject { { "paramname", item2.Key }, { "title",APIManager.GetParamTitle(item2.Key) }, { "paramvalue", item2.Value }, { "desc", "" } }; jarr_new.Add(jo_item); } jo.Add("list", jarr_new); } mySQL.AddField("Postdata", jo.ToString()); if (is_update) { db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where Url=@Url", mySQL); } else { db.Insert(mySQL); } } db.Free(); } } catch(Exception ex) { MessageBox.Show(ex.Message); } } this.Invoke(new Action(() => { #region 将获得的结果显示出来 if (result.Html.Length > 1024 * 1024 * 100) { this.RichHtml.Text = "获取失败,您要获取的网页超过100MB,暂时无法获取。"; highlightEditor1.Text = "获取失败,您要获取的网页超过100MB,暂时无法获取。"; } else { if (result.StatusCode == System.Net.HttpStatusCode.Redirect) { if (!ChkJump.Checked) { switch (MessageBox.Show("当前Url需要跳转,是否勾选跳转重试获取?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { case DialogResult.Yes: ChkJump.Checked = true; IsRunning = false; BtnRunHtml_Click(sender, e); return; } } } RichHtml.Text = string.Empty; if (this.ChkGetPic.Checked) { pictureBox1.Image = this.ByteArrayToImage(result.ResultByte); RichHtml.Visible = false; pictureBox1.Visible = true; tabControl2.SelectedIndex = 0; AddUrl("", TxtUrl.Text); } else { this.RichHtml.Text = result.Html; if(result.Html.IndexOfEx(" 0) { _html += "\r\n"; } _html += _format_html[i]; } //try //{ // var html2 = JJCCX.Xml.HtmlFormater.ConvertToXml(_html, true); // scintilla1.Text = html2; //} //catch(Exception ex) //{ // scintilla1.Text = _html; //} IndentLibrary.HtmlIndent indent = new IndentLibrary.HtmlIndent(); try { highlightEditor1.SetHightlightText(indent.Beautify(_html).Trim(), "html"); } catch { highlightEditor1.SetHightlightText(_html, "html"); } if (result.StatusCode == System.Net.HttpStatusCode.Redirect || result.StatusCode == System.Net.HttpStatusCode.OK) { string title = ""; try { HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(result.Html); var anchors = htmlDoc.DocumentNode.SelectNodes("//title"); if (anchors != null && anchors.Count > 0) { title = RyWeb.WebDecode.ConvertHtmlInner(anchors[0].InnerText); } } catch { } AddUrl(title, TxtUrl.Text); } } this.RichHtml.Visible = true; this.pictureBox1.Visible = false; } } this.RichCookie.Text = result.Cookie; var timespan = (dt_end - dt).TotalMilliseconds.ToInt(); string timespan_str = ""; if (timespan < 1000) { timespan_str = timespan + "毫秒"; } else { timespan_str = timespan / 1000 + "秒" + timespan % 1000 + "毫秒"; } this.RichStatus.Text = "StatusCode:" + result.StatusCode.ToString()+"["+ (int)result.StatusCode+ "]" + "\r\nStatusDescription:" + result.StatusDescription + "\r\n提交时间:" + dt.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n响应耗时:" + timespan_str+"\r\n"+"实际地址:"+ result.ResponseUri; this.RichHeader.Text = ""; if (result.Header != null) { foreach (string str1 in result.Header.AllKeys) { string text = this.RichHeader.Text; this.RichHeader.Text = text + str1 + ":" + result.Header[str1].ToString() + "\r\n"; } } if (!ChkNoPreview.Checked) { if (ChkHtmlPreview.Checked) { if (!this.CbbEncoding.Text.Contains("自动")) { extendedWebBrowser1.LoadStrings(RichHtml.Text.Trim(), Encoding.GetEncoding(this.CbbEncoding.Text.Trim())); } else { extendedWebBrowser1.LoadStrings(RichHtml.Text.Trim()); } //MessageBox.Show(extendedWebBrowser1.Document.Encoding); //extendedWebBrowser1.Document.Encoding = Encoding.UTF8.BodyName; } else { if (RbGet.Checked) { extendedWebBrowser1.Navigate(TxtUrl.Text, null, null, TxtInputHeader.Text); } else { string strData = TxtPost.Text; string strHeaders = "Content-Type: " + CbbContentType.Text + "\r\n" + TxtInputHeader.Text; ASCIIEncoding AE = new ASCIIEncoding(); byte[] bytePost = AE.GetBytes(strData); //byte[] byteHeaders = AE.GetBytes(strHeaders); extendedWebBrowser1.Navigate(TxtUrl.Text, null, bytePost, strHeaders); } } } #endregion })); } catch (Exception exception) { this.Invoke(new Action(() => { if (IsExit) { this.RichHtml.Text = "用户中断执行"; BtnRunHtml.Text = "执行"; IsRunning = false; } else { this.RichHtml.Text = exception.Message; } highlightEditor1.Text = ""; })); } this.Invoke(new Action(() => { BtnRunHtml.Text = "执行"; IsRunning = false; })); } } private Image ByteArrayToImage(byte[] Bytes) { MemoryStream stream = new MemoryStream(Bytes); return Image.FromStream(stream, true); } private void TxtUrl_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { BtnRunHtml.PerformClick(); } else if (e.KeyCode == Keys.Down) { if (objectListView2.Visible) { objectListView2.SelectedObject = null; objectListView2.SelectedIndex = 0; objectListView2.Focus(); } } } private void FrmWebGet_Load(object sender, EventArgs e) { List autoc_list = new List(); autoc_list.AddRange(RyFiles.ReadAllLines(Application.StartupPath + "\\SysDb\\AutoComplete\\post.txt")); TxtPost.SetAutoCompleteList(autoc_list); //TxtPost.AutoWordSelection = false; System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //加上这一句 var highlight_menu = (ContextMenuStripHighlightText2)highlightEditor1.ContextMenuStrip; highlight_menu.AddSeparatorMenu(); highlight_menu.AddMenu("将选中的内容作为Json分析", "").Click += AnalyJson_Click; for (int i = 0; i < this.Controls.Count; i++) { switch (this.Controls[i]) { case GroupBox gb: gb.Click += Gb_Click; break; } } ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; } private bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; } private void Gb_Click(object sender, EventArgs e) { objectListView2.Visible = false; //RbGet.Focus(); switch ((this.DockPanel.FindForm())) { case Form1 frm: frm.HideDownList(); break; } } private void AnalyJson_Click(object sender, EventArgs e) { ContextMenuStrip menu =(ContextMenuStrip) (((ToolStripMenuItem)sender).Owner); switch(menu.SourceControl) { case ScintillaNETV2.Scintilla rich_txt: var SelectedText= rich_txt.SelectedText; if (SelectedText == "") { SelectedText = rich_txt.Text; } //if (Manager.Json.IsJson(SelectedText)) { FrmJson frm = new FrmJson(); frm.Show(this.DockPanel); frm.LoadJson(SelectedText); } break; case RichTextBox rich_txt2: var SelectedText2 = rich_txt2.SelectedText; if (SelectedText2 == "") { SelectedText2 = rich_txt2.Text; } //if (Manager.Json.IsJson(SelectedText2)) { FrmJson frm = new FrmJson(); frm.Show(this.DockPanel); frm.LoadJson(SelectedText2); } break; } } private void BtnCtreateCShape_Click(object sender, EventArgs e) { } public void AddUrl(string title,string url) { IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { var _title = title; if(_title.Length==0) { var mode = url.Replace("?","&").GetStr("&a=",""); if (mode.IndexOf("&") > 0) { mode = mode.GetStr("", "&"); } if(mode.Length==0) { mode = url.Replace("?", "&").GetStr("&Action=", ""); if (mode.IndexOf("&") > 0) { mode = mode.GetStr("", "&"); } } if (mode.Length == 0) { mode = url.Replace("?", "&").GetStr("&api=", ""); if (mode.IndexOf("&") > 0) { mode = mode.GetStr("", "&"); } } _title = mode; } RyQuickSQL mySQL = new RyQuickSQL("Urls"); mySQL.AddField("Name", _title); mySQL.AddField("Url", url); mySQL.AddField("Cookie", TxtCookie.Text); mySQL.AddField("Postdata", TxtPost.Text); mySQL.AddField("Header", TxtInputHeader.Text); var method = ""; if (RbHead.Checked) { method="head"; } else { method= RbGet.Checked ? "get" : "post"; } mySQL.AddField("Method", method); mySQL.AddField("UserAgent", CbbUserAgent.Text); mySQL.AddField("Referer", CbbReferer.Text); mySQL.AddField("ContentType", CbbContentType.Text); mySQL.AddField("Encoding", CbbEncoding.Text); DataSet ds = db.ReadData("select * from Urls where Url=@Url", mySQL); if (ds.HaveData()) { DataRow reader = ds.Tables[0].Rows[0]; #region 读取信息 mySQL.AddFieldCalc("ClickCount", "ClickCount+1");//点击次数 mySQL.AddField("editTime", DateTime.Now); db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + reader["id"].ToString(), mySQL); #endregion } else { mySQL.AddField("ClickCount",1); mySQL.AddField("editTime", DateTime.Now); mySQL.AddField("addTime", DateTime.Now); db.ExecuteNonQuery(mySQL.GetInsertSQL(),mySQL); } ds?.Dispose(); IDbInterface db2 = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db2.ConnDb(Itrycn_Db.History_SQLConn) == 1) { mySQL.TableName = "HistoryUrl"; var md5 = rySafe.MD5Sha1.GetMD5(url + "|" + TxtPost.Text + "|" + TxtInputHeader.Text + "|" + method + "|" + CbbReferer.Text + "|" + CbbContentType.Text); mySQL.AddField("MD5", md5); DataSet ds_his = db2.ReadData("select * from HistoryUrl where Url=@Url and MD5=@MD5", mySQL); if(ds_his.HaveData()) { DataRow reader = ds_his.Tables[0].Rows[0]; #region 读取信息 mySQL.AddFieldCalc("ClickCount", "ClickCount+1");//点击次数 mySQL.Remove("addTime"); db2.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + reader["id"].ToString(), mySQL); #endregion } else { mySQL.AddField("ClickCount", 1); mySQL.AddField("addTime", DateTime.Now); db2.ExecuteNonQuery(mySQL.GetInsertSQL(), mySQL); } ds_his?.Dispose(); } db2.Free(); } db.Free(); } bool proc_use = false; private bool IsAddNewUrl = false; private void ClickItem(bool run = false) { if (objectListView2.SelectedObject!=null) { TxtCookie.Text = ""; TxtInputHeader.Text = ""; var item = (UrlInfo)objectListView2.SelectedObject; objectListView2.Visible = false; Application.DoEvents(); proc_use = true; string url = item.Url; IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { db.AddParameter("url", url); DataSet ds = db.ReadData("select * from Urls where Url=@url", db.GetParameter()); if(ds.HaveData()) { DataRow row = ds.Tables[0].Rows[0]; SetValueByRich(TxtCookie,"Cookie"); SetValueByHightlight(TxtPost, "Postdata"); SetValueByRich(TxtInputHeader, "Header"); SetValue2(CbbUserAgent, "UserAgent"); SetValue(CbbReferer, "Referer"); SetValue2(CbbContentType, "ContentType"); SetValue3(CbbEncoding, "Encoding"); if (row["Method"].ToString().Length>0) { if(row["Method"].ToString()=="post") { RbPost.Checked = true; } else if (row["Method"].ToString() == "head") { RbHead.Checked = true; } else { RbGet.Checked = true; } } void SetValueByRich(ryControls.Controls.RichTextBox2 txt, string Field) { if (row[Field].ToString().Length > 0) { txt.Text = row[Field].ToString(); txt.Refresh(); } else { txt.Text =""; txt.Refresh(); } } void SetValueByHightlight(ScintillaNETV2.Highlight.HighlightEditor txt, string Field) { if (row[Field].ToString().Length > 0) { txt.Text = row[Field].ToString(); txt.Refresh(); } } void SetValue2(ryControls.ComboBoxEx2 cbb, string Field) { if (row[Field].ToString().Length>0) { var have = false; for (int i = 0; i < cbb.Items.Count; i++) { if(cbb.Items[i] is ComboPopupItem item2) { if(item2.ValueStr1== row[Field].ToString()) { cbb.SelectedIndex = i; have = true; break; } } } if (!have) { cbb.Text = row[Field].ToString(); } } } void SetValue3(ryControls.RyComboBox cbb, string Field) { if (row[Field].ToString().Length > 0) { cbb.Text = row[Field].ToString(); } } void SetValue(ryControls.TextBoxEx2 cbb, string Field) { if (row[Field].ToString().Length > 0) { cbb.Text = row[Field].ToString(); } } } db.Free(); } TxtUrl.Text = url; IsAddNewUrl = false; if (TxtCookie.Text != "") { tabPage2.Text = "Cookie(有数据)"; } else { tabPage2.Text = "Cookie"; } if (TxtInputHeader.Text != "") { tabPage7.Text = "Header(有数据)"; } else { tabPage7.Text = "Header"; } if (run) { BtnRunHtml.PerformClick(); } proc_use = false; } else { objectListView2.Visible = false; } } private void Table1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Up) { if (objectListView2.SelectedObject!=null && objectListView2.SelectedIndex==0) { objectListView2.SelectedObject = null; TxtUrl.Select(); TxtUrl.Focus(); //rySearch1.Select(); } } else if (e.KeyCode == Keys.Enter) { ClickItem(); } } private void TxtUrl_TextChanged2(object sender, EventArgs e) { if (proc_use) { return; } string sql_where = " where 1=1"; if (TxtUrl.Text != "") { sql_where = " where (Name like @SearchText or Url like @SearchText or Des like @SearchText)"; } #region 重新载入数据 objectListView2.ClearObjects(); List list = new List(); IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { db.AddParameter("SearchText", "%" + TxtUrl.Text + "%"); db.AddParameter("today",DateTime.Now.Date); Dictionary dict_icon = new Dictionary(); DataSet ds2 = db.ReadData("select * from Urls" + sql_where + " and editTime>=@today order by IsFav desc,editTime desc", db.GetParameter()); for (int i = 0; i < ds2.Tables[0].Rows.Count; i++) { DataRow row = ds2.Tables[0].Rows[i]; DateTime editTime = row["editTime"].ToDateTime(); Image icon = null; try { var uri = new Uri(row["Url"].ToString()); if(dict_icon.ContainsKey(uri.Host)) { icon=dict_icon[uri.Host]; } else { if (System.IO.File.Exists(Application.StartupPath + "\\SysDb\\webicons\\" + uri.Host + ".png")) { icon = RyImage.LoadPic(Application.StartupPath + "\\SysDb\\webicons\\" + uri.Host + ".png"); } else if (System.IO.File.Exists(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".ico")) { icon = RyImage.LoadPic(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".ico"); } else if (System.IO.File.Exists(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".png")) { icon = RyImage.LoadPic(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".png"); } dict_icon[uri.Host] = icon; } } catch { } var item = new UrlInfo() { Id = row["id"].ToInt(), Name = row["Name"].ToString(), Des = row["Des"].ToString(), Url = row["Url"].ToString(), ClickCount = row["ClickCount"].ToInt(), Fav = row["IsFav"].ToInt() == 1, Icon=icon }; if (editTime >= DateTime.Now.AddMinutes(-10)) { list.Insert(0, item); } else { list.Add(item); } } ds2?.Dispose(); DataSet ds = db.ReadData("select * from Urls" + sql_where+ " and editTime<@today order by IsFav desc,date(editTime) desc,ClickCount desc", db.GetParameter()); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = ds.Tables[0].Rows[i]; DateTime editTime = row["editTime"].ToDateTime(); Image icon = null; try { var uri = new Uri(row["Url"].ToString()); if (dict_icon.ContainsKey(uri.Host)) { icon = dict_icon[uri.Host]; } else { if (System.IO.File.Exists(Application.StartupPath + "\\SysDb\\webicons\\" + uri.Host + ".png")) { icon = RyImage.LoadPic(Application.StartupPath + "\\SysDb\\webicons\\" + uri.Host + ".png"); } else if (System.IO.File.Exists(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".ico")) { icon = RyImage.LoadPic(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".ico"); } else if (System.IO.File.Exists(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".png")) { icon = RyImage.LoadPic(Application.StartupPath + "\\UserDb\\webicons\\" + uri.Host + ".png"); } dict_icon[uri.Host] = icon; } } catch { } var item = new UrlInfo() { Id = row["id"].ToInt(), Name = row["Name"].ToString(), Des = row["Des"].ToString(), Url = row["Url"].ToString(), ClickCount = row["ClickCount"].ToInt(), Fav = row["IsFav"].ToInt()==1, Icon=icon }; if (editTime >= DateTime.Now.AddMinutes(-10)) { list.Insert(0,item); } else { list.Add(item); } } ds?.Dispose(); db.Free(); objectListView2.AddObjects(list); objectListView2.Visible = list.Count != 0; objectListView2.BringToFront(); } IsAddNewUrl = true; #endregion } private void FrmWebGet_Click(object sender, EventArgs e) { objectListView2.Visible = false; } private void Table1_CellLostFocus(object sender, XPTable.Events.CellFocusEventArgs e) { if (e.Row == -1) { objectListView2.Visible = false; } } private void Table1_Leave(object sender, EventArgs e) { if(!TxtUrl.Focused) { objectListView2.Visible = false; } } private void TxtUrl_Leave(object sender, EventArgs e) { if (IsAddNewUrl && !objectListView2.Visible) { if (TxtCookie.Text.Length > 0 && TxtInputHeader.Text.Length > 0) { if (MessageBox.Show("你修改了新Url,是否要清空Cookie和Header?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { TxtCookie.Text = ""; TxtInputHeader.Text = ""; } } else if (TxtCookie.Text.Length > 0) { if (MessageBox.Show("你修改了新Url,是否要清空Cookie?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { TxtCookie.Text = ""; } } else if (TxtInputHeader.Text.Length > 0) { if (MessageBox.Show("你修改了新Url,是否要清空Header?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { TxtInputHeader.Text = ""; } } if (CbbReferer.Text.Length > 0) { if (MessageBox.Show("你修改了新Url,是否要清空引用页?", "询问", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { CbbReferer.Text = ""; } } } if (!objectListView2.Focused) { objectListView2.Visible = false; } } private void Table1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ClickItem(); } } private void TxtPost_DoubleClick(object sender, EventArgs e) { //Start(); if (tabControl2.SelectedTab == tabPage12) { highlightEditor1.Focus(); } new Thread(Start).Start(); void Start() { Thread.Sleep(100); this.Invoke(new Action(() => { var post = TxtPost.Text; if (post.StartsWith("{", StringComparison.OrdinalIgnoreCase)) { bool isJson = false; try { var json_text = Manager.Json.ConvertJsonString(post); isJson = true; FrmJson frm = new FrmJson(); frm.BtnSave.Visible = true; frm.toolStripSeparator1.Visible = true; frm.menuRight1.SourceContent = null; frm.Format(json_text); frm.Size = new Size(1200, 900); frm.StartPosition = FormStartPosition.Manual; RyForm.ShowCenter(frm, this.ParentForm); if (frm.ShowDialog()==DialogResult.OK) { try { JObject jo = (JObject)JsonConvert.DeserializeObject(frm.highlightEditor1.Text); var aa = Newtonsoft.Json.JsonConvert.SerializeObject(jo, new Newtonsoft.Json.JsonSerializerSettings() { StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeNonAscii }); TxtPost.Text = aa; BtnRunHtml.PerformClick(); } catch (Exception ex) { MessageBox.Show(ex.Message, "出错", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { } if (!isJson) { 开发辅助工具.Controls.FrmText frm = new Controls.FrmText { Icon = Icon }; frm.highlightEditor1.Visible = true; frm.richTextBox1.Visible = false; frm.highlightEditor1.SetHightlightText(post, "txt"); if (frm.ShowDialog() == DialogResult.OK) { try { JObject jo = (JObject)JsonConvert.DeserializeObject(frm.highlightEditor1.Text); var aa = Newtonsoft.Json.JsonConvert.SerializeObject(jo, new Newtonsoft.Json.JsonSerializerSettings() { StringEscapeHandling = Newtonsoft.Json.StringEscapeHandling.EscapeNonAscii }); TxtPost.Text = aa; BtnRunHtml.PerformClick(); } catch (Exception ex) { MessageBox.Show(ex.Message, "出错", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } else { ShowAPIDialog(); } })); } } private void TxtPost_TextChanged(object sender, EventArgs e) { if (TxtPost.Text != "") { tabPage1.Text = "Post数据(有数据)"; } else { tabPage1.Text = "Post数据"; } } private void TxtCookie_TextChanged(object sender, EventArgs e) { if (TxtCookie.Text != "") { tabPage2.Text = "Cookie(有数据)"; } else { tabPage2.Text = "Cookie"; } } private void TxtInputHeader_TextChanged(object sender, EventArgs e) { if (TxtInputHeader.Text != "") { tabPage7.Text = "Header(有数据)"; } else { tabPage7.Text = "Header"; } } private void ChkNoPreview_CheckedChanged(object sender, EventArgs e) { ChkHtmlPreview.Enabled = !ChkNoPreview.Checked; } private void 置顶收藏该项ToolStripMenuItem_Click(object sender, EventArgs e) { var item = (UrlInfo)objectListView2.SelectedObject; if (item == null) { return; } IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { RyQuickSQL mySQL = new RyQuickSQL("Urls"); mySQL.AddField("IsFav", item.Fav ? 0 : 1); db.ExecuteNonQuery(mySQL.GetUpdateSQL()+" where id="+item.Id,mySQL); item.Fav = !item.Fav; objectListView2.RefreshObject(item); } db.Free(); } private void ContextMenuStrip1_Opening(object sender, CancelEventArgs e) { var item = (UrlInfo)objectListView2.SelectedObject; if (item == null) { return; } 置顶收藏该项ToolStripMenuItem.Text = item.Fav ? "取消收藏该项" : "置顶收藏该项"; } private void 删除该项ToolStripMenuItem_Click(object sender, EventArgs e) { var item = (UrlInfo)objectListView2.SelectedObject; if (item == null) { return; } if(item.ClickCount>5) { switch (MessageBox.Show("确认要删除该项记录吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)) { case DialogResult.No: return; } } IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { db.ExecuteNonQuery("delete from Urls where id=" + item.Id); objectListView2.RemoveObject(item); } db.Free(); } private void 设置备注ToolStripMenuItem_Click(object sender, EventArgs e) { var item = (UrlInfo)objectListView2.SelectedObject; if (item == null) { return; } IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1) { 开发辅助工具.Controls.FrmTitle frm = new 开发辅助工具.Controls.FrmTitle(); frm.TxtTitle.Text = item.Des; if (frm.ShowDialog() == DialogResult.OK) { RyQuickSQL mySQL = new RyQuickSQL("Urls"); mySQL.AddField("Des", frm.TxtTitle.Text); db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where id=" + item.Id, mySQL); item.Des = frm.TxtTitle.Text; objectListView2.RefreshObject(item); } } db.Free(); } private void BtnMore_Click(object sender, EventArgs e) { SuperPictureBox btn = (SuperPictureBox)sender; Point p = new Point(0, btn.Height); MenuMore.Items.Clear(); AddMenu("API编辑器", "api"); try { var uri = new Uri(TxtUrl.Text); AddMenu("查看历史记录", "history_url"); var host = uri.Host.ToLower(); if(host.IndexOfEx("www.87g")==0 || host.IndexOfEx("www.3h3") == 0 ||host.IndexOfEx("www.downxia") == 0 || host.IndexOfEx("www.downbank") == 0 || host.IndexOfEx("www.downxing") == 0 || host.IndexOfEx("downwn.com") == 0) { List list = new List { new MenuTag() { Title = "切换到【87G】87g.com", Site = "https://www.87g.com" }, new MenuTag() { Title = "切换到【87G】87g.cn", Site = "https://www.87g.cn" }, new MenuTag() { Title = "-", Site = "" }, new MenuTag() { Title = "切换到【当游】3h3.com", Site = "https://www.3h3.com" }, new MenuTag() { Title = "切换到【当游】3h3.cn", Site = "https://www.3h3.cn" }, new MenuTag() { Title = "-", Site = "" }, new MenuTag() { Title = "切换到【当下】downxia.com", Site = "https://www.downxia.com" }, new MenuTag() { Title = "切换到【当下】downxia.cn", Site = "https://www.downxia.cn" }, new MenuTag() { Title = "-", Site = "" }, new MenuTag() { Title = "切换到【当星网】downxing.com", Site = "https://www.downxing.com" }, new MenuTag() { Title = "切换到【当星网】downxing.cn", Site = "https://www.downxing.cn" }, new MenuTag() { Title = "-", Site = "" }, new MenuTag() { Title = "切换到【玩能网】downwn.com", Site = "https://downwn.com" } }; AddMenu("-", ""); for (int i = 0; i < list.Count; i++) { if (list[i].Title=="-") { MenuMore.Items.Add(list[i].Title); continue; } if (list[i].Site.IndexOfEx(host)>=0) {continue;} AddMenu(list[i].Title, list[i].Site); } if (MenuMore.Items.Count>0 && MenuMore.Items[MenuMore.Items.Count-1].Text=="") { MenuMore.Items[MenuMore.Items.Count - 1].Visible = false; } } } catch { } MenuMore.Show(btn, p); void AddMenu(string title, string site) { ToolStripItem item = MenuMore.Items.Add(title); item.Tag= new MenuTag() { Site = site }; item.Click += Item_Click; } } /// /// 显示API编辑器 /// private void ShowAPIDialog() { var have_error = false; Uri uri = null; try { uri = new Uri(TxtUrl.Text); } catch { have_error = true; } try { if (RbPost.Checked) { RyWeb.UrlData urldata = new RyWeb.UrlData(); have_error=!urldata.Load(TxtPost.Text); } } catch { have_error = true; } if (have_error) { MessageBox.Show("API编辑器不支持当前内容。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (uri != null) { TxtPost.Focus(); APIEditor frm = new APIEditor(); frm.LoadData(uri, TxtPost.Text, RbGet.Checked); if (frm.ShowDialog() == DialogResult.OK) { if (RbGet.Checked) { TxtUrl.Text = uri.Scheme + "://" + uri.Host + (uri.Port == 80 ? "" : (":" + uri.Port)) + uri.AbsolutePath + "?" + frm.SelectedPostDatas; } else { TxtPost.Text = frm.SelectedPostDatas; } } frm.Dispose(); } } private void Item_Click(object sender, EventArgs e) { if(sender is ToolStripItem item) { if(item.Tag is MenuTag menuTag) { if(menuTag.Site=="api") { ShowAPIDialog(); return; } if (menuTag.Site.Length == 0) { return; } var url = TxtUrl.Text; if (menuTag.Site == "history_url") { FrmHistoryUrls frm = new FrmHistoryUrls(); frm.Icon = Icon; frm.LoadDb(url); if(frm.ShowDialog(this) == DialogResult.OK) { IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType); if (db.ConnDb(Itrycn_Db.History_SQLConn) == 1) { DataSet ds = db.ReadData("select * from HistoryUrl where Id="+frm.SelectedId); if (ds.HaveData()) { DataRow row = ds.Tables[0].Rows[0]; SetValueByRich(TxtCookie, "Cookie"); SetValueByHightlight(TxtPost, "Postdata"); SetValueByRich(TxtInputHeader, "Header"); SetValue(CbbReferer, "Referer"); SetValue2(CbbContentType, "ContentType"); SetValue3(CbbEncoding, "Encoding"); if (TxtCookie.Text != "") { tabPage2.Text = "Cookie(有数据)"; } else { tabPage2.Text = "Cookie"; } if (TxtInputHeader.Text != "") { tabPage7.Text = "Header(有数据)"; } else { tabPage7.Text = "Header"; } if (row["Method"].ToString().Length > 0) { if (row["Method"].ToString() == "post") { RbPost.Checked = true; } else if (row["Method"].ToString() == "head") { RbHead.Checked = true; } else { RbGet.Checked = true; } } void SetValueByRich(ryControls.Controls.RichTextBox2 txt, string Field) { if (row[Field].ToString().Length > 0) { txt.Text = row[Field].ToString(); txt.Refresh(); } else { txt.Text = ""; txt.Refresh(); } } void SetValueByHightlight(HighlightEditor txt, string Field) { if (row[Field].ToString().Length > 0) { txt.Text = row[Field].ToString(); txt.Refresh(); } } void SetValue(ryControls.TextBoxEx2 cbb, string Field) { if (row[Field].ToString().Length > 0) { cbb.Text = row[Field].ToString(); } } void SetValue2(ryControls.ComboBoxEx2 cbb, string Field) { if (row[Field].ToString().Length > 0) { cbb.Text = row[Field].ToString(); } } void SetValue3(ryControls.RyComboBox cbb, string Field) { if (row[Field].ToString().Length > 0) { cbb.Text = row[Field].ToString(); } } } ds?.Dispose(); db.Free(); } TxtUrl.Text = url; } frm.Dispose(); return; } var pos = url.IndexOfEx("//"); if(pos>=0) { pos = url.IndexOfEx("/", pos + 2); if(pos>0) { proc_use = true; TxtUrl.Text= menuTag.Site+ url.Substring(pos); proc_use = false; } } } } } class MenuTag { public string Title { get; set; } public string Site { get; set; } } private void RbGet_CheckedChanged(object sender, EventArgs e) { if(RbGet.Checked) TxtPost.Enabled = false; } private void RbPost_CheckedChanged(object sender, EventArgs e) { if (RbPost.Checked) TxtPost.Enabled = true; } private void TxtCookie_DoubleClick(object sender, EventArgs e) { ryControls.Controls.RichTextBox2 txt = (ryControls.Controls.RichTextBox2)sender; 开发辅助工具.Controls.FrmText frm = new Controls.FrmText { Icon = Icon }; frm.richTextBox1.Text = txt.Text; if (frm.ShowDialog() == DialogResult.OK) { txt.Text = frm.richTextBox1.Text; } } private void RbHead_CheckedChanged(object sender, EventArgs e) { if (RbHead.Checked) TxtPost.Enabled = false; } private void BtnSetting_Click(object sender, EventArgs e) { SuperPictureBox btn = (SuperPictureBox)sender; Point p = new Point(0, btn.Height); MenuSetting.Show(btn, p); } private HttpItem GetCodes() { string str = GetMethod(); HttpItem item = new HttpItem { URL = TxtUrl.Text.Trim(), Method = str, Cookie = this.TxtCookie.Text.Trim(), Referer = this.CbbReferer.Text.Trim(), Postdata = this.TxtPost.Text.Trim(), Timeout = Convert.ToInt32(this.CbbTimeout.Text.Replace("秒", string.Empty).Trim()) * 0x3e8, ReadWriteTimeout = Convert.ToInt32(this.CbbWriteTimeout.Text.Replace("秒", string.Empty).Trim()) * 0x3e8, UserAgent = this.CbbUserAgent.Text, ContentType = this.CbbContentType.Text, Allowautoredirect = this.ChkJump.Checked, ResultType = ChkGetPic.Checked ? ResultType.Byte : ResultType.String }; if (CbbUserAgent.SelectedIndex != -1) { if (CbbUserAgent.SelectedItem is ComboPopupItem info2) { item.UserAgent = info2.ValueStr1; } } if (!string.IsNullOrEmpty(this.CbbIp.Text.Trim())) { item.ProxyIp = this.CbbIp.Text.Trim(); } if (!this.CbbEncoding.Text.Contains("自动")) { item.Encoding = Encoding.GetEncoding(this.CbbEncoding.Text.Trim()); } if (TxtInputHeader.Text.Length > 0) { try { string[] item_header = TxtInputHeader.Text.Replace("\r", "").Split('\n'); for (int i = 0; i < item_header.Length; i++) { var split = item_header[i].Split(':'); if (split.Length == 2) { if (split[0].ToLower() == "accept") { item.Accept = split[1]; continue; } else if (split[0].ToLower() == "content-type") { item.ContentType = split[1]; continue; } } item.Header.Add(item_header[i]); } } catch (Exception exception) { } } return item; } private void 生成代码ToolStripMenuItem_Click(object sender, EventArgs e) { HttpItem item = GetCodes(); this.RichHtml.Visible = true; this.pictureBox1.Visible = false; //this.SetHttpItem(); StringBuilder builder = new StringBuilder(); builder.Append(" HttpHelper http = new HttpHelper();\r\n"); builder.Append(" HttpItem item = new HttpItem()\r\n"); builder.Append(" {\r\n"); builder.Append(" URL = \"" + item.URL + "\",//URL 必需项 \r\n"); if (!this.CbbEncoding.Text.Trim().Contains("自动")) { builder.Append(" Encoding = System.Text.Encoding.GetEncoding( \"" + this.CbbEncoding.Text.Trim() + "\"),//URL 可选项 默认为Get \r\n"); } builder.Append(" Method = \"" + item.Method + "\",//URL 可选项 默认为Get \r\n"); builder.Append(" Cookie = \"" + item.Cookie.Replace("\n", "\"+\n \"") + "\",//字符串Cookie 可选项 \r\n"); builder.Append(" Referer =\"" + item.Referer + "\",//来源URL 可选项 \r\n"); builder.Append(" Accept = \"" + item.Accept + "\",//Accept 可选项 \r\n"); builder.Append(" Postdata = \"" + item.Postdata.Replace("\n", "\"+\n \"") + "\",//Post数据 可选项GET时不需要写 \r\n"); builder.Append(" Timeout = " + item.Timeout + ",//连接超时时间 可选项默认为100000 \r\n"); builder.Append(" ReadWriteTimeout = " + item.ReadWriteTimeout + ",//写入Post数据超时时间 可选项默认为30000 \r\n"); builder.Append(" UserAgent = \"" + item.UserAgent + "\",//用户的浏览器类型,版本,操作系统 可选项有默认值 \r\n"); builder.Append(" ContentType = \"" + item.ContentType + "\",//返回类型 可选项有默认值 \r\n"); builder.Append(" Allowautoredirect = " + item.Allowautoredirect.ToString().ToLower() + ",//是否根据301跳转 可选项 \r\n"); builder.Append(" //CerPath = \"d:\\123.cer\",//证书绝对路径 可选项不需要证书时可以不写这个参数 \r\n"); builder.Append(" //Connectionlimit = 1024,//最大连接数 可选项 默认为1024 \r\n"); builder.Append(" ProxyIp = \"" + item.ProxyIp + "\",//代理服务器ID 可选项 不需要代理 时可以不设置这三个参数 \r\n"); builder.Append(" //ProxyPwd = \"123456\",//代理服务器密码 可选项 \r\n"); builder.Append(" //ProxyUserName = \"administrator\",//代理服务器账户名 可选项 \r\n"); builder.Append(" ResultType = " + (ChkGetPic.Checked ? "ResultType.Byte" : "ResultType.String") + "\r\n"); builder.Append(" };\r\n"); if (TxtInputHeader.Text.Length > 0) { try { string[] item_header = TxtInputHeader.Text.Replace("\r", "").Split('\n'); for (int i = 0; i < item_header.Length; i++) { var split = item_header[i].Split(':'); if (split.Length == 2) { if (split[0].ToLower() == "accept") { continue; } else if (split[0].ToLower() == "content-type") { continue; } } builder.Append(" item.Header.Add(\""+ item_header[i]+"\");\r\n"); //item.Header.Add(item_header[i]); } } catch (Exception exception) { } } builder.Append(""); builder.Append(" HttpResult result = http.GetHtml(item);\r\n"); builder.Append(" string html = result.Html;\r\n"); builder.Append(" string cookie = result.Cookie;\r\n"); if (ChkGetPic.Checked) { builder.Append(" \r\n\r\n"); builder.Append(" /// \r\n"); builder.Append(" /// 字节数组生成图片\r\n"); builder.Append(" /// \r\n"); builder.Append(" /// 字节数组\r\n"); builder.Append(" /// 图片\r\n"); builder.Append(" private Image byteArrayToImage(byte[] Bytes)\r\n"); builder.Append(" {\r\n"); builder.Append(" MemoryStream ms = new MemoryStream(Bytes);\r\n"); builder.Append(" return Bitmap.FromStream(ms,true);\r\n"); builder.Append(" }\r\n"); } RichHtml.Text = builder.ToString(); highlightEditor1.SetHightlightText(builder.ToString(), "c#"); tabControl2.SelectedTab = tabPage12; } private string GetMethod() { string str = "get"; if (RbGet.Checked) { str = "get"; } if (RbPost.Checked) { str = "post"; } if (RbHead.Checked) { str = "head"; } return str; } private void 导出当前设置ToolStripMenuItem_Click(object sender, EventArgs e) { if(TxtUrl.Text.Length==0) { MessageBox.Show("请先输入网址。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } try { JObject jo = new JObject { { "SoftVer", RySoft.VersionStr }, { "Url", TxtUrl.Text }, { "Method", GetMethod() }, { "Encoding", CbbEncoding.Text }, { "Timeout", CbbTimeout.Text }, { "WriteTimeout", CbbWriteTimeout.Text }, { "Jump_On", ChkJump.Checked }, { "GetPic_On", ChkGetPic.Checked }, { "NoPreview_On", ChkNoPreview.Checked }, { "HtmlPreview_On", ChkHtmlPreview.Checked }, { "ContentType", CbbContentType.Text }, { "UserAgent", CbbUserAgent.Text }, { "Ip", CbbIp.Text }, { "Referer", CbbReferer.Text }, { "Post", TxtPost.Text }, { "Cookie", TxtCookie.Text }, { "InputHeader", TxtInputHeader.Text } }; RyWeb.QuickWeb web = new RyWeb.QuickWeb(); var http = web.Post("http://gs2.3h3.com:8081/DyV2.aspx", "api=QuickUrl&Method=set&qText=" + web.UrlEncode(jo.ToString())); if (http.StatusCode == HttpStatusCode.OK) { var json = JObject.Parse(http.Html); var guid = json.GetJsonValue("guid", ""); if (guid.Length > 0) { RyFiles.CopyToClip("qurl://" + guid + "/"); Itrycn_Db.last_clip_text = "qurl://" + guid + "/"; MessageBox.Show("已复制到剪切板", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("导出出错", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("导出失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch(Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void 导入当前设置ToolStripMenuItem_Click(object sender, EventArgs e) { try { var quick_url = Clipboard.GetText(); if (quick_url.IndexOfEx("qurl://") >= 0) { var guid = quick_url.GetStr("qurl://", "/"); if (quick_url.Length > 0) { RyWeb.QuickWeb web = new RyWeb.QuickWeb(); var http = web.Post("http://gs2.3h3.com:8081/DyV2.aspx", "api=QuickUrl&Method=get&guid=" + web.UrlEncode(guid)); if (http.StatusCode == HttpStatusCode.OK) { var json = JObject.Parse(http.Html); var qText = json.GetJsonValue("qText", ""); if (qText.Length > 0) { proc_use = true; var json_set = JObject.Parse(qText); var Method = json_set.GetJsonValue("Method", ""); if (Method == "get") { RbGet.Checked = true; } else if (Method == "post") { RbPost.Checked = true; } else if (Method == "head") { RbHead.Checked = true; } else { RbGet.Checked = true; } TxtUrl.Text = json_set.GetJsonValue("Url", ""); IsAddNewUrl = false; CbbEncoding.Text = json_set.GetJsonValue("Encoding", ""); CbbTimeout.Text = json_set.GetJsonValue("Timeout", ""); CbbWriteTimeout.Text = json_set.GetJsonValue("WriteTimeout", ""); ChkJump.Checked = json_set.GetJsonValue("Jump_On", true); ChkGetPic.Checked = json_set.GetJsonValue("GetPic_On", false); ChkNoPreview.Checked = json_set.GetJsonValue("NoPreview_On", true); ChkHtmlPreview.Checked = json_set.GetJsonValue("HtmlPreview_On", false); CbbContentType.Text = json_set.GetJsonValue("ContentType", ""); CbbUserAgent.Text = json_set.GetJsonValue("UserAgent", ""); CbbIp.Text = json_set.GetJsonValue("Ip", ""); CbbReferer.Text = json_set.GetJsonValue("Referer", ""); TxtPost.Text = json_set.GetJsonValue("Post", ""); TxtCookie.Text = json_set.GetJsonValue("Cookie", ""); TxtInputHeader.Text = json_set.GetJsonValue("InputHeader", ""); proc_use = false; BtnRunHtml.PerformClick(); } else { MessageBox.Show("没有找到该配置信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("从剪切板里没有找到配置", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("从剪切板里没有找到配置2", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch(Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void FrmWebGet_Activated(object sender, EventArgs e) { } private void BtnShare_Click(object sender, EventArgs e) { 导出当前设置ToolStripMenuItem.PerformClick(); } private void TxtPost_EnabledChanged(object sender, EventArgs e) { label1.Visible = !TxtPost.Enabled; } private void 生成curl代码ToolStripMenuItem_Click(object sender, EventArgs e) { if(ChkGetPic.Checked) { MessageBox.Show("暂不支持当前选项的curl代码生成,请更改选项。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } HttpItem item = GetCodes(); this.RichHtml.Visible = true; this.pictureBox1.Visible = false; //this.SetHttpItem(); string curl = "curl -A '"+ item.UserAgent + "'"; curl += " -H '" + item.Accept + "'"; curl += " -H '" + item.ContentType + "'"; if (TxtInputHeader.Text.Length > 0) { try { string[] item_header = TxtInputHeader.Text.Replace("\r", "").Split('\n'); for (int i = 0; i < item_header.Length; i++) { var split = item_header[i].Split(':'); if (split.Length == 2) { if (split[0].ToLower() == "accept") { continue; } else if (split[0].ToLower() == "content-type") { continue; } } curl += " -H '" + item_header[i] + "'"; } } catch (Exception exception) { } } curl += " -H 'charset=" + (item.Encoding==null?"utf-8": item.Encoding.BodyName)+ "'"; curl += " -b '" + item.Cookie.Replace("\\n", "\\\\n").Replace("\r", "").Replace("\n", "\\n") + "'"; if (item.Referer.Length > 0) { curl += " -e '" + item.Referer + "'"; } if (item.Postdata.Length > 0 && item.Method.ToUpper() == "POST") { curl += " -d '" + item.Postdata.Replace("\\n", "\\\\n").Replace("\r","").Replace("\n","\\n") + "'"; } if(item.Method.ToUpper() == "POST") { curl += " -X POST"; } else if (item.Method.ToUpper() == "GET") { curl += " -X GET"; } else if (item.Method.ToUpper() == "HEAD") { curl += " -X HEAD"; } if(item.Timeout>0) { curl += " --connect-timeout "+(item.Timeout/1000); } if (item.ReadWriteTimeout > 0) { curl += " --max-time " + (item.ReadWriteTimeout / 1000); } curl += " '"+item.URL+"'"; RichHtml.Text = curl; highlightEditor1.SetHightlightText(curl, "bat"); tabControl2.SelectedTab = tabPage12; } private void CbbUserAgent_SelectedIndexChanged(object sender, EventArgs e) { if (CbbUserAgent.SelectedIndex != -1) { if (CbbUserAgent.SelectedItem is ComboPopupItem info2) { CbbUserAgent.ToolTipText= info2.ValueStr1; } else { CbbUserAgent.ToolTipText = CbbUserAgent.Text; } } else { CbbUserAgent.ToolTipText = CbbUserAgent.Text; } } } public class UrlInfo { public int Id { get; set; }=0; public string Url { get; set; } = ""; public string Name { get; set; } = ""; public string Des { get; set; } = ""; public int ClickCount { get; set; } = 0; /// /// 是否收藏 /// public bool Fav { get; set; } = false; public Image Icon { get; set; } = null; } }