private TaskAccessCheckCache ToCache3(Task arg2) { var arg1 = new TaskAccessCheckCache(); var access = BCT.Context.BulletinDb.Accesses.Find(arg2.AccessId); if (access != null) { arg1.AccessId = access.Id; arg1.Login = access.Login; arg1.Password = access.Password; } return(arg1); }
public override void ActivateBulletins(FirefoxDriver driver, TaskAccessCheckCache taskModel) { try { var inactivePage = @"www.avito.ru/profile/items/inactive"; if (!Auth(driver, taskModel.Login, taskModel.Password)) { return; } WaitPage(driver, 3000, inactivePage); WaitExecute(driver); var ids = new List <string>(); var nextPagePattern = "(Следующая страница)"; var buttonPattern = "profile-item-title\">[\\s\\S\\r\\n]*?<a name=\"item_([\\d]+)"; var count = 1; var hasNextPage = true; while (hasNextPage) { count++; var html = driver.PageSource; hasNextPage = !string.IsNullOrEmpty(RegexHelper.GetValue(nextPagePattern, html)); var matches = RegexHelper.Execute(buttonPattern, html).ToArray(); if (matches.Any()) { ids.AddRange(matches.Select(q => q.Groups[1].Value)); } if (hasNextPage) { driver.Navigate().GoToUrl("http://" + inactivePage + $"/rossiya?p={count}&s=4"); WaitPage(driver, 30000, inactivePage + $"/rossiya?p={count}&s=4"); } } foreach (var id in ids) { SendMessage($"ActivateBulletins => Trying to activate bulletin with Id {id}"); var activationLink = @"http://www.avito.ru/packages/put_free_package?item_id=" + id; driver.Navigate().GoToUrl(activationLink); //WaitExecute(driver); } } catch (Exception ex) { } }
static void TestActivate() { var avito = new Avito(); var task = new TaskAccessCheckCache { Login = "******", Password = "******" }; FirefoxHelper.ExecuteWithVisual(browser => { browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika"); avito.ActivateBulletins(browser, task); }, null, 100); }
static void TestGetStatistics() { var avito = new Avito(); var task = new TaskAccessCheckCache { AccessId = new Guid("BBC4B038-7309-4299-BB59-D8F0119EB7B5"), Login = "******", Password = "******" }; FirefoxHelper.ExecuteWithVisual(browser => { browser.Navigate().GoToUrl("https://www.avito.ru/moskva/bytovaya_elektronika"); var stat = avito.GetAccessStatistics(browser, task); if (stat != null) { var access = AccessHelper.GetAccess(task.AccessId); access.Views = stat.Views; access.Messages = stat.Messages; access.Calls = stat.Calls; AccessHelper.Save(access); } }, null, 100); }
private Task ToEntity4(TaskAccessCheckCache arg1, Task arg2) { return(arg2); }
public override bool CheckAccess(FirefoxDriver driver, TaskAccessCheckCache taskModel) { return(Auth(driver, taskModel.Login, taskModel.Password)); //return Auth(driver, "*****@*****.**", "Zcvb208x"); }
public override AccessStatistics GetAccessStatistics(FirefoxDriver driver, TaskAccessCheckCache taskModel) { AccessStatistics result = null; try { if (!Auth(driver, taskModel.Login, taskModel.Password)) { return(null); } //Сбор просмотров var totalViews = 0; var rawViews = new List <string>(); var nextPagePattern = "(Следующая страница)"; var viewPattern = "class=\"profile-item-views-count-icon[\\s\\S\\r\\n]*?(\\d+)"; var count = 1; var hasNextPage = true; while (hasNextPage) { count++; var html = driver.PageSource; hasNextPage = !string.IsNullOrEmpty(RegexHelper.GetValue(nextPagePattern, html)); var matches = RegexHelper.Execute(viewPattern, html).ToArray(); if (matches.Any()) { rawViews.AddRange(matches.Select(q => q.Groups[1].Value)); } if (hasNextPage) { driver.Navigate().GoToUrl($"http://www.avito.ru/profile/items/active/rossiya?p={count}&s=4"); WaitPage(driver, 30000, $"www.avito.ru/profile/items/active/rossiya?p={count}&s=4"); } } foreach (var rawView in rawViews) { var success = Int32.TryParse(rawView, out var viewCount); if (success) { totalViews += viewCount; } } //Сбор сообщений driver.Navigate().GoToUrl($"http://www.avito.ru/profile/messenger"); WaitPage(driver, 30000, $"www.avito.ru/profile/messenger"); var pageSource = driver.PageSource; var totalMessages = 0; var messagePattern = "(messenger-channel-context)"; var messageMatches = RegexHelper.Execute(messagePattern, pageSource).ToArray(); totalMessages = messageMatches.Count(); var stat = new AccessStatistics(); stat.Views = totalViews; stat.Messages = totalMessages; result = stat; } catch (Exception ex) { } return(result); }