コード例 #1
0
ファイル: Form1.cs プロジェクト: psyblade12/Phanmemdowntruyen
 private void button11_Click(object sender, EventArgs e)
 {
     flowLayoutPanel2.Controls.Clear();
     using (var client = new WebClient())
     {
         string chuoitimkiem = txtTenTruyenMGK.Text.Trim().ToLower().Replace(" ", "+");
         string url          = "http://mangak.info/?s=" + chuoitimkiem + "&q=" + chuoitimkiem;
         client.DownloadFile(url, "file.txt");
         using (StreamReader sr = new StreamReader("file.txt"))
         {
             String line = sr.ReadToEnd();
             line = XulyHTML.PreXulyTimKiemMGK(line);
             line = XulyHTML.XuLyTimKiemMGK(line);
             line = XulyHTML.XulyHauTimKiemMGK(line);
             List <string> dstruyentimthay = line.Split(';').ToList();
             foreach (string s in dstruyentimthay)
             {
                 Label lb = new Label();
                 lb.Text        = s + "";
                 lb.AutoSize    = true;
                 lb.MouseClick += new MouseEventHandler(lb_click);
                 flowLayoutPanel2.Controls.Add(lb);
                 Label lb2 = new Label();
                 lb2.Text     = ";";
                 lb2.AutoSize = true;
                 flowLayoutPanel2.Controls.Add(lb2);
             }
         }
     }
 }
コード例 #2
0
ファイル: Form4.cs プロジェクト: psyblade12/Phanmemdowntruyen
 private void Form4_Load(object sender, EventArgs e)
 {
     try
     {
         string tentruyen = txtTenTruyenMGK.Text;
         //MessageBox.Show(_tentruyen);
         //MessageBox.Show(_tap);
         //MessageBox.Show(_dai);
         //MessageBox.Show(_cao);
         //string tentruyen = txtTenTruyenMGK.Text;
         _tentruyen           = _tentruyen.ToLower();
         _tentruyen           = _tentruyen.Trim();
         _tentruyen           = _tentruyen.Replace(" ", "-");
         txtChapter.Text      = _tap;
         txtTenTruyenMGK.Text = _tentruyen;
         using (var client = new WebClient())
         {
             string url = "http://mangak.info/" + _tentruyen + "-chap-" + _tap.Replace(".", "-") + "/";
             if (RemoteFileExists(url) == true)
             {
                 client.DownloadFile(url, "file.txt");
                 using (StreamReader sr = new StreamReader("file.txt"))
                 {
                     String line     = sr.ReadToEnd();
                     string tam      = "<div class=\"vung_doc\">";
                     int    vitridau = line.IndexOf(tam);
                     line = line.Substring(vitridau);
                     int vitridivgannhat = line.IndexOf("</div>");
                     line = line.Substring(0, vitridivgannhat);
                     line = line.Replace(tam, "");
                     line = line.Replace("</div>", "");
                     line = line.Trim();
                     line = line.Replace("\r\n", ";");
                     line = line.Replace("<img src=\"", "");
                     line = xoakituthua(line);
                     line = xoakituthua2(line);
                     line = line.Replace("jpg", "jpg?imgmax=" + txtDoLon.Text);
                     line = line.Replace("jpeg", "jpeg?imgmax=" + txtDoLon.Text);
                     line = line.Replace("png", "png?imgmax=" + txtDoLon.Text);
                     //string[] links = line.Split(';');
                     dsdownload = line.Split(';').ToList();
                     if (radioButton1.Checked == true)
                     {
                         button6.Visible      = true;
                         button5.Visible      = true;
                         lblTrang.Visible     = true;
                         txtTrang.Visible     = true;
                         btnChonTrang.Visible = true;
                         lblTrang.Text        = "Trang: " + (demhienthi + 1).ToString();
                         flowLayoutPanel1.Controls.Clear();
                         PictureBox pb = new PictureBox();
                         pb.ImageLocation = dsdownload[demhienthi];
                         pb.SizeMode      = PictureBoxSizeMode.AutoSize;
                         pb.MouseClick   += new MouseEventHandler(pb_click);
                         flowLayoutPanel1.Controls.Add(pb);
                         Label lb = new Label();
                         lb.Text = " ";
                         flowLayoutPanel1.Controls.Add(lb);
                         lblTrang.Text = "Trang: " + (demhienthi + 1) + "/" + (dsdownload.Count());
                     }
                     else
                     {
                         button6.Visible      = false;
                         button5.Visible      = false;
                         lblTrang.Visible     = false;
                         txtTrang.Visible     = false;
                         btnChonTrang.Visible = false;
                         flowLayoutPanel1.Controls.Clear();
                         foreach (string s in dsdownload)
                         {
                             PictureBox pb = new PictureBox();
                             pb.ImageLocation = s;
                             pb.SizeMode      = PictureBoxSizeMode.AutoSize;
                             flowLayoutPanel1.Controls.Add(pb);
                         }
                     }
                 }
             }
         }
         using (var client = new WebClient())
         {
             string url = "http://mangak.info/" + txtTenTruyenMGK.Text + "-chap-" + txtChapter.Text + "/";
             client.DownloadFile(url, "file.txt");
             using (StreamReader sr = new StreamReader("file.txt"))
             {
                 String line     = sr.ReadToEnd();
                 string tam      = "<select class=\"select-chapter\">";
                 int    vitridau = line.IndexOf(tam);
                 line = line.Substring(vitridau);
                 int vitridivgannhat = line.IndexOf("</select>");
                 line = line.Substring(0, vitridivgannhat);
                 //
                 line = line.Replace(tam, "");
                 line = line.Replace("<option value=\"", "");
                 line = line.Trim();
                 line = line.Replace("</option>", "");
                 line = line.Replace("\r\n", ";");
                 line = xoakituthuasochapter(line);
                 if (line.IndexOf(" - Tập") > -1)
                 {
                     line = line + ";((((";
                     line = XulyHTML.XoaChuTap(line);
                 }
                 sochapter              = line.Split(';');
                 comboBox1.DataSource   = sochapter;
                 comboBox1.SelectedItem = txtChapter.Text;
             }
         }
         lanhienthidau = false;
     }
     catch
     {
         MessageBox.Show("Có lỗi xảy ra");
     }
 }