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 renameAccountToolStripMenuItem_Click(object sender, EventArgs e) { Thread t = new Thread(() => { this.SetInfo("start rename "); Parallel.ForEach(SelectAccount(), new ParallelOptions() { MaxDegreeOfParallelism = 3 }, (acc) => { acc.Proxie = null; DriverInstance instance = new DriverInstance(); this.SetInfo("start rename " + acc.UserName); if (string.IsNullOrEmpty(acc.Proxie)) { instance.InitDriver(false); } else { instance.InitDriver(false, acc.Proxie.Replace("_", ":")); } var pin = new Pinterest(instance.Driver); pin.MakeLogin(acc.Email, acc.Password); if (pin.CheckLogin()) { this.SetInfo("cant logined " + acc.UserName); pin.FillName(); var accountNewName = pin.AccountInfo(acc); AccountManager.Accounts.Where(x => x.Email == acc.Email).FirstOrDefault().FullName = accountNewName.FullName; AccountManager.GetInstance().Save(); } else { this.SetInfo("cant login " + acc.UserName); } }); }); 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(); }