static void Main(string[] args) { //Делаем компилятор счастливым string username = ""; System.Console.WriteLine("OZWar Bot v1.0"); System.Console.WriteLine("Инициализация IE..."); //Инициализация ватина WatiN.Core.IE ieb = new IE("http://ozwar.ru/forum/index.php?app=core&module=global§ion=login"); ieb.Visible = false; int ii = 0; while (ii == 0) { System.Console.WriteLine("Авторизация..."); ieb.WaitForComplete(); //Вводим данные System.Console.WriteLine("Введите имя пользователя:"); username = System.Console.ReadLine(); System.Console.WriteLine("Введите пароль:"); string password = System.Console.ReadLine(); ieb.TextField(WatiN.Core.Find.ByName("ips_username")).TypeText(username); ieb.TextField(WatiN.Core.Find.ByName("ips_password")).TypeText(password); ieb.Button(WatiN.Core.Find.ByClass("input_submit")).Click(); ieb.WaitForComplete(); if (ieb.Link(WatiN.Core.Find.ByTitle(username)).Exists) { ii = 1; } } //Смотрим баланс ieb.GoTo(ieb.Link(WatiN.Core.Find.ByTitle(username)).Url); ieb.WaitForComplete(); System.Console.WriteLine("Баланс: " + ieb.Span(WatiN.Core.Find.ByClass("fc")).Text.ToString()); System.Console.WriteLine("Грузим ссылки..."); //Грузим ссылки var ar1 = new List<string>(); System.IO.StreamReader file = new System.IO.StreamReader(@"c:\list.txt"); string line; while ((line = file.ReadLine()) != null) { ar1.Add(line); } //Грузим фразы System.Console.WriteLine("Грузим фразы..."); var ar2 = new List<string>(); System.IO.StreamReader file2 = new System.IO.StreamReader(@"c:\phrases.txt"); string line2 = ""; while ((line2 = file2.ReadLine()) != null) { ar2.Add(line2); } int co = 0; while (co < ar1.Count) { ieb.GoTo(ar1[co]); ieb.WaitForComplete(); if (!ieb.Link(WatiN.Core.Find.ByTitle("Изменить")).Exists) { System.Console.WriteLine("Текущая ссылка: " + ar1[co]); int rnd = RandomInt(0, ar2.Count); System.Console.WriteLine("Пишем"); ieb.TextField(WatiN.Core.Find.ByName("Post")).TypeTextQuickly(ar2[rnd] + "[color=#222222]Эта информация тут только для дебага, цыц, вы этого не видели. Не, ну серьёзно. Ну, а раз видели, значит её сейчас, к сожалению, сейчас не станет. Это сообщение отправлено ботом OreNew, пожалуйста, не читайте его.[/color]"); ieb.Form(WatiN.Core.Find.ById("ips_fastReplyForm")).Submit(); ieb.WaitForComplete(); ieb.GoTo(ieb.Link(WatiN.Core.Find.ByTitle("Изменить")).Url); ieb.WaitForComplete(); ieb.TextField(WatiN.Core.Find.ByName("Post")).TypeText(ar2[rnd]); ieb.Form(WatiN.Core.Find.ById("postingform")).Submit(); System.Console.WriteLine("Выполнено"); ieb.GoTo("http://ozwar.ru/forum/index.php?/user/609-benderfromfuture/"); ieb.WaitForComplete(); System.Console.WriteLine("Баланс: " + ieb.Span(WatiN.Core.Find.ByClass("fc")).Text.ToString()); co++; } else { System.Console.WriteLine("Найдены следы нас!"); co++; } System.Console.WriteLine("Ссылки кончились, бот завершил свою работу"); ieb.Link(WatiN.Core.Find.ByTitle("Выход")).Click(); System.Console.WriteLine("Выход из профиля..."); System.Console.ReadLine(); } }
public void RequestContacts() { // this test does a full end-to-end integration (request token, user authoriazation, exchanging request token // for an access token and then using then access token to retrieve some data). // the access token is directly associated with a google user, by them logging in and granting access // for your request - thus the client is never exposed to the users credentials (not even their login). IOAuthSession consumer = CreateGoogleContactsSession(); using (With.NoCertificateValidation()) { IToken requestToken = consumer.GetRequestToken(); string userAuthorize = consumer.GetUserAuthorizationUrlForToken(requestToken, null); string verificationCode; using (var ie = new IE(userAuthorize)) { Link overrideLink = ie.Link("overridelink"); if (overrideLink.Exists) overrideLink.Click(); if (ie.Form("gaia_loginform").Exists) { ie.TextField("Email").Value = "*****@*****.**"; ie.TextField("Passwd").Value = "oauth_password"; ie.Form("gaia_loginform").Submit(); } ie.Button("allow").Click(); string html = ie.Html; Assert.True(html.Contains("Authorized") || html.Contains("successfully granted")); int index = html.IndexOf("verification code:"); Assert.True(index > 0); int startIndex = html.IndexOf("<B>", index, StringComparison.InvariantCultureIgnoreCase); int endIndex = html.IndexOf("</B>", startIndex + 1, StringComparison.InvariantCultureIgnoreCase); verificationCode = html.Substring(startIndex + 3, endIndex - (startIndex + 3)); } // this will implicitly set AccessToken on the current session... IToken accessToken = consumer.ExchangeRequestTokenForAccessToken(requestToken, verificationCode); try { string responseText = consumer.Request().Get().ForUrl("https://www.google.com/m8/feeds/contacts/default/base").ToString(); Assert.True(responseText.Contains("*****@*****.**")); } catch (WebException webEx) { var response = (HttpWebResponse) webEx.Response; using (var reader = new StreamReader(response.GetResponseStream())) { throw new Exception("WebException was thrown upon request, response content follows:\r\n\r\n" + reader.ReadToEnd(), webEx); } } } }