Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using Gravity.Services.Comet.Services;
- using Gravity.Services.DataContracts;
- using Gravity.Services.DataContracts.Dto;
- using Gravity.Services.DataContracts.Dto.Enums;
- using OpenQA.Selenium.Interactions;
- namespace Generic_Crawlers_Solution_Net
- {
- class Program
- {
- private static CancellationTokenSource _cancellationTokenSource = new CancellationTokenSource();
- private static CancellationToken cancellationToken = _cancellationTokenSource.Token;
- static void Main(string[] args)
- {
- RunAsync(cancellationToken).Wait();
- Thread.Sleep(Timeout.Infinite);
- }
- private static async Task RunAsync(CancellationToken cancellationToken)
- {
- var request = new WebAutomation
- {
- AuthenticationInformation = new AuthenticationInformation { UserName = "ludlamzgull@gmail.com", Password = "Kikoeludad1!" },
- EngineConfiguration = new EngineConfiguration { ElementSearchingTimeout = 500, PageLoadTimeout = 60000 },
- DriverParams = @"{""Platform"":""Chrome"",""DriverSource"":""Local"",""DriverAssemblies"":""Binaries.WebDrivers""}",
- Actions = new[]
- {
- new ActionRule {ActionType = ActionType.GoToUrl, Argument ="http://dutchimports.co.uk" },
- new ActionRule {ActionType = ActionType.SendKeys, ElementToActOn = "//input[@id='product-search']", Argument = "Christian"},
- new ActionRule {ActionType = ActionType.Wait, Argument = "5"},
- new ActionRule {ActionType = ActionType.CloseBrowser}
- }
- };
- while (!cancellationToken.IsCancellationRequested)
- {
- await Task.Factory.StartNew(() =>
- {
- var client = new Orbit();
- client.RunWebAutomationSequence(request);
- });
- await Task.Delay(TimeSpan.FromSeconds(5));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement