Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using OpenQA.Selenium;
- using OpenQA.Selenium.Chrome;
- using System.Threading;
- using TwoCaptcha.Captcha;
- using TwoCaptcha;
- public class BingXAtomatic
- {
- static void Main(string[] args)
- {
- // Read data from the file
- string filePath = "C:\\bot\\1234.txt";
- var credentials = ReadCredentialsFromFile(filePath);
- IWebDriver driver = new ChromeDriver();
- driver.Navigate().GoToUrl("https://bingx.com/ru-ru/register");
- IWebElement usernameElement = driver.FindElement(By.XPath("//*[@id=\"__layout\"]/div/div[1]/div/div/div/div[4]/div/div/input"));
- IWebElement passwordElement = driver.FindElement(By.XPath("//*[@id=\"__layout\"]/div/div[1]/div/div/div/div[5]/div/div/input"));
- // Assuming credentials is a KeyValuePair<string, string>
- usernameElement.SendKeys(credentials.Key);
- Thread.Sleep(10000);
- passwordElement.SendKeys(credentials.Value);
- IWebElement register = driver.FindElement(By.XPath("//*[@id=\"__layout\"]/div/div[1]/div/div/div/button"));
- register.Click();
- CaptchaSolve(driver);
- }
- private static void CaptchaSolve(IWebDriver driver)
- {
- TwoCaptcha.TwoCaptcha solver = new TwoCaptcha.TwoCaptcha("API");
- GeeTestV4 captcha = new GeeTestV4();
- captcha.SetCaptchaId("3dd5c2c85ab5702b553993389dc41859&challenge=365be3fa-a1b1-400b-bdbb-d21ad3898641&client_type=web&lang=rus&callback=geetest_170223272441");
- captcha.SetUrl("https://bingx.com/ru-ru/register");
- try
- {
- solver.Solve(captcha).Wait();
- Console.WriteLine("Captcha solved: " + captcha.Code);
- SendCaptchaSolutionToServer(driver, captcha.Code);
- }
- catch (AggregateException e)
- {
- Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
- }
- }
- private static void SendCaptchaSolutionToServer(IWebDriver driver, string captchaSolution)
- {
- using (var httpClient = new HttpClient())
- {
- var content = new FormUrlEncodedContent(new[]
- {
- new KeyValuePair<string, string>("captcha_solution", captchaSolution),
- // Add any other parameters needed by the server
- });
- var response = httpClient.PostAsync("https://bingx.com/ru-ru/register/", content).Result;
- // Check the response status or perform further actions based on the server response
- if (response.IsSuccessStatusCode)
- {
- Console.WriteLine("Captcha solution sent successfully");
- }
- else
- {
- Console.WriteLine($"Failed to send captcha solution. Status code: {response.StatusCode}");
- }
- }
- }
- // Function to read email and password from a file
- static KeyValuePair<string, string> ReadCredentialsFromFile(string filePath)
- {
- try
- {
- string[] lines = File.ReadAllLines(filePath);
- if (lines.Length > 0)
- {
- string[] parts = lines[0].Split(':');
- if (parts.Length == 2)
- {
- string email = parts[0].Trim();
- string password = parts[1].Trim();
- return new KeyValuePair<string, string>(email, password);
- }
- else
- {
- Console.WriteLine("Invalid formot");
- }
- }
- else
- {
- Console.WriteLine("File is empty.");
- }
- }
- catch(Exception ex)
- {
- Console.WriteLine($"{ex.Message}");
- }
- return default;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement