private void inserisciDettagli(int id)
        {
            HtmlNodeCollection nodesAll = docDetailes.DocumentNode.SelectNodes(@"(//table[@class='tbl3']|//h2)");

            for (int nc = 0; nc < nodesAll.Count; nc++)// parto all'incontrario per un fattore d'indice
            {
                HtmlNode node = nodesAll[nc];
                if (node.Attributes.Count == 1 && node.Attributes[0].Value == "tbl3")
                {
                    doctemp.LoadHtml(node.InnerHtml);
                    HtmlNodeCollection rows = doctemp.DocumentNode.SelectNodes(@"(//tr)");
                    for (int i = 1; i < rows.Count; i++)// saltro la prima riga
                    {
                        HtmlNode noderow = rows[i];
                        doctempRow.LoadHtml(noderow.InnerHtml);
                        HtmlNodeCollection   trows = doctempRow.DocumentNode.SelectNodes(@"(//td)");
                        QuotazioniVinciteRow row   = Variabili._QuatazioniVinciteRow_newRow();
                        row.id = id;
                        row.enumTipoVincita = "";
                        if (trows[0].InnerText == "")
                        {
                            continue;
                        }
                        string valore = Normalize(trows[1].InnerText);
                        if (valore == "-")
                        {
                            valore = "0";
                        }
                        string[] valuta = valore.Split(" ");//valore, valuta
                        row.valore = valuta[0];
                        if (valuta.Length > 1)
                        {
                            row.valuta = valuta[1];
                        }
                        row.vincitori       = int.Parse(Normalize(trows[2].InnerText).Replace(".", ""));
                        row.premio          = trows[0].InnerText;
                        row.enumTipoVincita = nodesAll[nc - 1].InnerText;
                        Variabili._QuatazioniVincite_addRow(row);
                        trows.Clear();
                    }
                    rows.Clear();
                }
            }
            nodesAll.Clear();
        }
Exemple #2
0
        private async void btnMagnet_Click(object sender, EventArgs e)
        {
            lbxMagnet.Items.Clear();
            magnets.Clear();
            if (lbxNum.SelectedIndex != -1)
            {
                string       magnetKeyword = Avers[lbxNum.SelectedIndex].Num;
                string       sukebei_url   = @"https://sukebei.nyaa.si/?f=0&c=0_0&q=" + magnetKeyword;
                HtmlDocument doc           = await ArzonHttp.GetHtmldocAsync(sukebei_url);

                if (doc != null)
                {
                    HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes(@"//tbody/tr");
                    if (nodes != null)
                    {
                        foreach (var node in nodes)
                        {
                            Magnet magnet = new Magnet();
                            magnet.SetInfo(node);
                            magnets.Add(magnet);
                        }
                        nodes.Clear();
                        foreach (var m in magnets)
                        {
                            lbxMagnet.Items.Add(m.title);
                        }
                    }
                    else
                    {
                        MessageBox.Show("未搜索到结果", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("网络连接超时,请配置代理", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("请在左侧列表选择番号", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemple #3
0
        private void _ParsingPeriodHtmlToFile(string myInFile, string myOutFile) //Parsing Previous read information about the periods
        {
            string[]      substringURL     = new string[15];
            string[]      substringFullURL = new string[15];
            string[]      substringYear    = new string[15];
            string[]      substringMonth   = new string[15];
            string[]      substrings;
            string        s;
            int           i     = 0;
            StringBuilder sb    = new StringBuilder();
            var           Coder = Encoding.GetEncoding(65001); //For Saving of The Pages to UTF8
            HtmlDocument  HD    = new HtmlDocument();

            try //Parsing URL, Month and Year and write their into the arrays
            {
                HD.LoadHtml(File.ReadAllText(myInFile).ToString());
                HtmlNodeCollection NoAltElements = HD.DocumentNode.SelectNodes("//td[@class='data2'][1]");

                if (NoAltElements != null)      // проверка на наличие найденных узлов
                {
                    foreach (HtmlNode HN in NoAltElements)
                    {
                        substringURL[i]   = HN.InnerText;
                        substrings        = Regex.Split(HN.InnerText, "-| ");
                        substringMonth[i] = substrings[1].Trim(new Char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' }); //Take only month
                        s = substrings[1];
                        substringYear[i] = s.Remove(4);
                        sb.AppendLine(HN.InnerText);
                        if (i < 13)
                        {
                            i++;
                        }
                    }
                }
                NoAltElements.Clear();
                toolStripStatusLabel1.Text = "Обработка завершена!";
            }
            catch (FileNotFoundException Expt)
            { MessageBox.Show(Expt.Message + "\nНет такого файла", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
            catch (Exception Expt)
            { MessageBox.Show(Expt.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }

            try
            { File.AppendAllText(myOutFile, sb.ToString(), Coder); }
            catch (Exception Expt)
            { MessageBox.Show(Expt.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }

            try
            {
                HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create("http://sarg.kiev.ais/PLOD/index.html");
                myHttpWebRequest.PreAuthenticate = true;
                NetworkCredential networkCredential = new NetworkCredential(textBoxLogin.Text.Trim(), textBoxPassword.Text.Trim());
                myHttpWebRequest.Credentials = networkCredential;
                HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
                using (StreamReader myStreamReader = new StreamReader(myHttpWebResponse.GetResponseStream(), Encoding.GetEncoding(20866)))
                {    //KOI8
                    HD.LoadHtml(myStreamReader.ReadToEnd());
                    HtmlNodeCollection NoAltElements = HD.DocumentNode.SelectNodes("//a");
                    if (NoAltElements != null)      // проверка на наличие найденных узлов
                    {
                        i = 0;
                        foreach (HtmlNode HN in NoAltElements)
                        {
                            if (HN.Attributes["href"] != null && !HN.Attributes["href"].Value.ToLower().Contains("sourceforge"))
                            {
                                string u = "http://sarg.kiev.ais/PLOD/" + HN.Attributes["href"].Value;
                                if (u.Contains("201")) //Проверка статистики только с 2010 по 2019 года
                                {
                                    substringFullURL[i] = u;
                                }
                                if (i < 13)
                                {
                                    i++;
                                }
                            }
                        }
                    }
                }
                myHttpWebResponse.Close();
                myHttpWebRequest.Abort();
            }
            catch (Exception Expt)
            { MessageBox.Show(Expt.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
            toolStripStatusLabel1.Text = "Обработка завершена!";

            //Write Setting of the State into checkBoxes
            foreach (CheckBox checkBox in this.Controls.OfType <CheckBox>())      //Перебираем все чекбоксы на форме
            {
                int k = Convert.ToInt32(checkBox.TabIndex);
                if (substringYear[k - 1] != null && substringYear[k - 1].Length == 4)
                {
                    checkBox.Text = substringYear[k - 1] + " " + substringMonth[k - 1];
                    checkBox.Tag  = substringURL[k - 1];
                    checkBox.AccessibleDescription = substringFullURL[k - 1];
                    checkBox.Visible = true;
                    checkBox.Enabled = true;
                }
            }
            sb = null;
            HD = null;
            buttonLoadSelectedData.Visible = true;
            buttonLoadSelectedData.Enabled = false;
        }
Exemple #4
0
 private void UpdateRows()
 {
     Rows?.Clear();
     Rows = GetAbsentRows(CurrentClass);
 }