Exemple #1
0
        private void DoWork()
        {
            using (var Request = new HttpRequest())
            {
                if (!Directory.Exists(_Path))
                {
                    Directory.CreateDirectory(_Path);
                }
                Request.AllowAutoRedirect = false;
                Request.Cookies           = new CookieDictionary();
                Request.UserAgent         = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)";
                string get = Request.Get("http://www.planetebook.com/free-ebooks.asp").ToString();

                List <string> Z = get.RegexParses("<li><a href=\"", "</a><br/>");
                _Count = Z.Count;
                for (int z = 0; z < Z.Count; z++)
                {
                    Book book = new Book(Request);

                    string[] s = Z[z].Replace("\"", "").Replace(": ", " ").Split('>');

                    if (book.SetBook(s[0]))
                    {
                        string path = _Path + s[1] + "\\";
                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        book.SaveURL(path);
                        book.SaveBook(path);
                        book.SaveImage(path);

                        ((MainForm)SC._form).AddList(s[1]);
                        _Remaints++;
                    }
                    else
                    {
                        z--;
                    }
                }
            }
        }