private void BT_Go_Click(object sender, EventArgs e) { if (TB_Address.Text.Trim().Length <= 0) { return; } txtHTML.Text = ""; string sAddress = TB_Address.Text; if (sAddress.ToLower().StartsWith("http://") == false && sAddress.ToLower().StartsWith("https://") == false) { sAddress = "http://" + sAddress; } if (HTMLultility.RemoteFileExists(sAddress) == false) { MessageBox.Show("Link không tồn tại", "MVT - Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TB_Address.Focus(); return; } using (WebClient client = new WebClient()) { try { txtHTML.Text = client.DownloadString(sAddress); } catch (Exception ex) { throw new Exception(ex.Message); } } }
private void BT_Go_Click(object sender, EventArgs e) { if (TB_Address.Text.Trim().Length <= 0) { return; } List_Email.Items.Clear(); List_Link.Items.Clear(); //TB_HTML.Text = ""; iIndex = 0; string sAddress = TB_Address.Text; if (sAddress.ToLower().StartsWith("http://") == false && sAddress.ToLower().StartsWith("https://") == false) { sAddress = "http://" + sAddress; } if (HTMLultility.RemoteFileExists(sAddress) == false) { MessageBox.Show("Link không tồn tại", "MVT - Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Warning); TB_Address.Focus(); return; } sHostname = HTMLultility.GetHotName(sAddress); Pic_Loading.Visible = true; List_Link.Items.Add(sAddress); List_Link.SelectedIndex = iIndex; thrHTML = new Thread(new ThreadStart(GetHTML)); thrHTML.Start(); timer1.Enabled = true; TB_Address.Enabled = false; BT_Go.Enabled = false; BT_Stop.Enabled = true; BT_ExportEmail.Enabled = false; BT_ExportLink.Enabled = false; }
private void GetHTML() { RefreshLabelLink(); RefreshLabelEmail(); //SetTextBox(""); sHTML = ""; string sAddress = List_Link.Items[iIndex].ToString(); sCurentPage = HTMLultility.GetCurentPage(sAddress); using (WebClient client = new WebClient()) { try { sHTML = client.DownloadString(sAddress); //SetTextBox(sHTML); } catch (Exception ex) { thrHTML.Abort(); if (HTMLultility.RemoteFileExists(sAddress) == false) { List_Link.Items.RemoveAt(iIndex); if (iIndex > 0) { iIndex--; } } throw new Exception(ex.Message); } } thrLink = new Thread(new ThreadStart(SearchLink)); thrLink.Start(); thrEmail = new Thread(new ThreadStart(SearchEmail)); thrEmail.Start(); }