Beispiel #1
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            string se = e.Argument as string;


            int           i       = 1;
            int           j       = 0;
            List <string> magnets = new List <string>(); //the lists where the magnets are saved
            MyWebClient   f2      = new MyWebClient();   //make a modified webclient


            i = 1;
            while (i < 3)
            {
                j = 0;
                while (j < 23)
                {
                    try    //download html,find the magnet with most seeders and save it to list magnets
                    {
                        string html = f2.DownloadString(UrlHtml + se + " s" + (i).ToString("00") + "e" + (++j).ToString("00") + "?field=seeders&sorder=desc");

                        Match m1 = Regex.Match(html, "href=\"magnet:\\s*(.+?)\\s*\"", RegexOptions.Singleline);

                        magnets.Add("magnet:" + m1.Groups[1].Value);
                        f2.Dispose();
                    }
                    catch (Exception ex)
                    {
                        magnets.Add(ex.Message);
                    }
                }
                i++;
            }


            while (magnets.Count != (i - 1) * j)
            {
            }
            e.Result = magnets;
        }