public void AccountCheck() { Setup(); AppendTextBox("start check account"); Task.Factory.StartNew(() => { Parallel.ForEach(Accounts, new ParallelOptions() { MaxDegreeOfParallelism = 14 }, (acc) => { AppendTextBox(acc.Email + " checked "); this.startedDriver++; DriverInstance drivers = new DriverInstance(); drivers.InitDriver(false); acc = CheckOneAccount(acc, drivers); drivers.SuperQuit(); this.stopedDriver++; this.succeAcction++; acc.Status = this.PinAction + DateTime.Now.ToString(); labelInfo.Text = Accounts.Count + "/start " + this.startedDriver + "/ stop " + this.stopedDriver + "/ good " + this.succeAcction; }); }); AppendTextBox("done "); }
private void addXmlToolStripMenuItem_Click(object sender, EventArgs e) { using (var fbd = new FolderBrowserDialog()) { DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) { string[] files = Directory.GetFiles(fbd.SelectedPath); foreach (var path in files) { if (path.Contains(".xml")) { DriverInstance drivers = new DriverInstance(); drivers.InitDriver(false); Console.WriteLine(path); Pinterest pin = new Pinterest(drivers.Driver); pin.MakeLogin(manager.Load(path)); if (!pin.CheckLogin()) { pin.MakeLogin(Path.GetFileNameWithoutExtension(path), "trance_333"); } if (pin.CheckLogin()) { if (pin.ValidName() == false) { pin.FillName(); } try { pin.AddImage(); } catch { } Account acc = new Account(); acc.Email = Path.GetFileNameWithoutExtension(path); acc.Password = "******"; acc = pin.AccountInfo(acc); AccountManager.Accounts.Add(acc); try { AccountManager.GetInstance().Save(); } catch { } } drivers.SuperQuit(); } File.Delete(path); } ; } } }
private void addAccountToolStripMenuItem1_Click_1(object sender, EventArgs e) { Thread t = new Thread(() => { List <Account> newAccount = new List <Account>(); string[] lines = File.ReadAllLines(@"C:\my_work_files\pinterest\res\good.txt"); foreach (string line in lines) { string[] linedata = line.Split(':'); if (newAccount.Any(x => x.Email == linedata[0])) { newAccount.Where(x => x.Email == linedata[0]).FirstOrDefault().Password = linedata[1]; } else { newAccount.Add(new Account() { Email = linedata[0].ToLower(), Password = linedata[1], }); } } List <string> already = new List <string>(); if (File.Exists(ALREADY)) { already = File.ReadAllLines(ALREADY).ToList(); } newAccount = newAccount.Where(p => !already.Any(p2 => p2 == p.Email)).ToList(); newAccount = newAccount.Where(p => !AccountManager.Accounts.Any(p2 => p2.Email == p.Email)).ToList(); SetInfo("Account count for test " + newAccount.Count()); newAccount.Reverse(); Parallel.ForEach(newAccount, new ParallelOptions() { MaxDegreeOfParallelism = 7 }, (acc) => { DriverInstance drivers = new DriverInstance(); SetInfo("Start checking" + acc.Email); if (already.Contains(acc.Email) || AccountManager.Accounts.Where(x => x.Email == acc.Email).Any()) { SetInfo("skip"); } else { drivers.InitDriver(false); Pinterest pin = new Pinterest(drivers.Driver); pin.MakeLogin(acc.Email, acc.Password); if (pin.CheckLogin()) { // SetInfo("finded checking" + acc.Email); var newAcc = pin.AccountInfo(acc); AccountManager.Accounts.Add(newAcc); AccountManager.GetInstance().Save(); } else if (pin.Error != "password reset") { try { File.AppendAllText(ALREADY, acc.Email + Environment.NewLine); } catch { } } } drivers.SuperQuit(); }); }); t.Start(); }
public void PinStart() { Setup(); AppendTextBox("start "); Thread t = new Thread(() => { Parallel.ForEach(Accounts, new ParallelOptions() { MaxDegreeOfParallelism = 7 }, (acc) => { DriverInstance drivers = new DriverInstance(); this.startedDriver++; try { AppendTextBox(acc.Email + " try login"); if (string.IsNullOrEmpty(acc.Proxie)) { drivers.InitDriver(show); } else { drivers.InitDriver(show, acc.Proxie.Replace("_", ":")); } Pinterest pin = new Pinterest(drivers.Driver); pin.MakeLogin(acc.Email, acc.Password); pin.UserName = acc.UserName; if (pin.CheckLogin()) { pin.SaveCookie(CookieManager.Filename(acc.Email, acc.Proxie.Replace('_', ':'))); if (pin.ValidName() == false) { pin.FillName(); } GUI.ActionInfo response = new ActionInfo(false, null); while (true) { switch (this.PinAction) { case PinAction.Follow: limit = 7; response = pin.Follow(); break; case PinAction.Repin: int d = RepinPinList.Count();; if (RepinPinList.Count() > succeAcction) { response = pin.Repin(RepinPinList[succeAcction], firstTime); } else { this.Close(); } firstTime = false; break; // case PinAction.RepinOther: pin.Driver.Url = "https://www.pinterest.com/"; var pinsElement = pin.Driver.FindElementsByCssSelector("[data-force-refresh]"); List <string> hrefs = new List <string>(); foreach (var item in pinsElement) { if (!hrefs.Contains(item.GetAttribute("href"))) { hrefs.Add(item.GetAttribute("href")); } } foreach (var href in hrefs) { response = pin.Repin(href, firstTime); if (response.Done == false) { break; } else { AppendTextBox(href); } firstTime = false; } break; case PinAction.FollowSelf: var newbies = AccountManager.Accounts.Where(x => x.Followers == 0); foreach (var item in newbies) { response = pin.Follow(item.UserName); if (response.Done == false) { drivers.SuperQuit(); } else { AlreadyFollowedMyAccount.Add(item.UserName); File.AppendAllLines(FOLLOWED, AlreadyFollowedMyAccount); } AppendTextBox(" followed " + item.UserName); } break; default: response = pin.MakePost(); break; } if (this.pinAction == PinAction.Follow && response.Done == true) { int?before = acc.Follow; DriverInstance temp = new DriverInstance(); temp.InitDriver(false); acc = CheckOneAccount(acc, temp); temp.SuperQuit(); if (before == acc.Follow) { AppendTextBox("not work " + this.PinAction + acc.Email); drivers.SuperQuit(); this.stopedDriver++; break; } } else if (this.pinAction == PinAction.Pin && response.Done == true) { File.AppendAllText(PINNED, response.Info + Environment.NewLine); } if (attemp.Keys.Contains(acc.Email)) { if (attemp[acc.Email] > limit) { AppendTextBox(this.PinAction + "= limit =" + acc.Email); drivers.SuperQuit(); } attemp[acc.Email]++; } else { attemp[acc.Email] = 0; } succeAcction++; AppendTextBox(this.PinAction + " - " + response.Done + " - " + response.Info); acc.Status = this.PinAction + DateTime.Now.ToString(); //if(response.Done == false) //{ // break; //} } } else { AppendTextBox(pin.Error + ":" + acc.Email); drivers.SuperQuit(); this.stopedDriver++; } this.SetInfo(); } catch (Exception ex) { DeleteProxie(acc.Proxie); acc.Proxie = null; AppendTextBox("delete proxy " + acc.Proxie.Replace("_", ":")); } finally { drivers.SuperQuit(); } }); }); t.Start(); }