public void check() { htmlBasicFunction hhh = new htmlBasicFunction(); string html = hhh.getHtml("http://qingshiluogu.lingd.cc/article-6388958-1.html"); string tz = hhh.tongZhi(html); string ip = hhh.IP(html); string sj = hhh.shengJi(html); string mail = hhh.theTT(html, "mail"); bool tzT = hhh.isTrue(tz); bool ipT = hhh.isTrue(ip); bool sjT = hhh.isTrue(sj); string tzV = hhh.theValue(tz); string ipV = hhh.theValue(ip); string sjV = hhh.theValue(sj); bool mailT = hhh.isTrue(mail); sjV = hhh.GetTextMid(sjV, ">", "</a>").Trim(); string ver = hhh.theTT(sj, "version"); int daxiao = string.Compare(ver, version); string sjXiangqing = hhh.theTT(sj, "详情"); // MessageBox.Show(sj, "通知!", MessageBoxButtons.OK); try { if (hhh.ping() == 0) { MessageBox.Show("您的网络没有连接好或者网络较慢", "出错", MessageBoxButtons.OK); return; } } catch { MessageBox.Show("您的网络没有连接好或者网络较慢", "出错", MessageBoxButtons.OK); return; } try { if (tzT == true && tzV != "error") { MessageBox.Show(tzV, "通知!", MessageBoxButtons.OK); } if (sjT == true && (daxiao > 0 || ver == "all") && sjV != "error") { MessageBox.Show("最新版本为" + ver + ",您的版本需要升级了!O(∩_∩)O~\r\n\r\n" + sjXiangqing, "通知!", MessageBoxButtons.OK); Process.Start(sjV); } if (ipT == true) { IPnew = ipV; IPT = 1; } } catch { MessageBox.Show("读取通知及升级信息失败,请联系我并报告此异常状况 O(∩_∩)O", "出错", MessageBoxButtons.OK); } }
private void Form1_Load(object sender, EventArgs e) { try { buttonNextPage.Visible = false; htmlBasicFunction hhh = new htmlBasicFunction(); this.Text += version; new Thread(check).Start(); //给右键菜单添加处理程序 contextMenuStrip1.ItemClicked += new ToolStripItemClickedEventHandler(myContextMenuStripItem_Click); } catch (Exception ed) { MessageBox.Show("Form1_Load 出错,请联系我报告这个问题", "出错", MessageBoxButtons.OK); } }
public void threadLoadNextPage() { //if (oldThreadIsRunning) //{ // MessageBox.Show("请等待搜索完成!", "提示!", MessageBoxButtons.OK); // return; //} buttonNextPage.Visible = false;//显示该按钮 oldThreadIsRunning = true; string url; if (IPT == 1) { url = "http://" + IPnew; } else { url = "http://209.85.228.22"; } while ((numOfHtmlPage < pageNumOfEachThread * pagePercent) && (pagePercent <= 17)) { try { if (ting) { ting = false; break; } htmlBasicFunction hhh = new htmlBasicFunction(); string str = textBox1.Text; str = hhh.ifCSharp(str); url = url + "/custom?q=" + str + "&newwindow=1&sitesearch=pan.baidu.com&hl=zh-CN&prmd=ivns&ei=XS22VJ7EJoingwSq8ICYBQ&start=" + numOfHtmlPage++ *10 + "&sa=N"; string html = hhh.getHtml(url); label2.Text = ""; IPisBad = true;//IP未被封 string[][] res = null; res = hhh.fileDeteil(html, 0); for (int k = 0; k < res.Length; k++) { //从新建的tabpage中取出listview控件并操作它,使显示搜索结果 //ListView listview = tabControl1.TabPages[tabControl1.TabCount - 1].Controls[0] as ListView; ListView listview = tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0] as ListView; res[k][0] = (num + 1) + " " + res[k][0]; listview.Items.AddRange(new ListViewItem[] { new ListViewItem(res[k]) }); num++; } } catch (Exception e) { MessageBox.Show("你的IP被服务器禁止了,稍等一两小时后恢复正常", "提示!", MessageBoxButtons.OK); break; } } if (pagePercent <= 16) { pagePercent++; } else { MessageBox.Show("这是最后一页了", "提示!", MessageBoxButtons.OK); } label2.Text = "搜索到" + num + "个资源"; buttonNextPage.Visible = true;//显示该按钮 oldThreadIsRunning = false; }