Я получаю следующую ошибку: счета открыты, но переход по URL-адресу не выполняется, и транзакции не выполняются. Моя цель — открыть учетные записи, чтобы перейти по URL-адресу и выполнить транзакции.
ждите VideoYukle(драйвер, токен);
функция, можете ли вы предоставить информацию о том, как мне следует редактировать этот код?
/>Было бы здорово, если бы вы предоставили пример кода
// YouTube Studio URL'si
private string youtubeStudioUrl = "https://studio.youtube.com";
// Profil dizinlerini bulur ve her biri için OpenUrlInChromeProfile çağırır
public async Task OpenYouTubeStudiosAsync(CancellationToken token)
{
string userDataPath = @"C:\Users\fehmi\AppData\Local\Google\Chrome\User Data"; // Kullanıcı verileri dizini
string[] profileDirectories = Directory.GetDirectories(userDataPath, "Profile *"); // Tüm profilleri bul
foreach (string profileDir in profileDirectories)
{
if (token.IsCancellationRequested)
break; // Eğer iptal edilmişse döngüyü kır
try
{
string profileName = new DirectoryInfo(profileDir).Name; // Profil adını al
Console.WriteLine($"Profil işleniyor: {profileName}");
// Her profil için YouTube Studio'yu aç
await OpenUrlInChromeProfile(profileName, token);
}
catch (Exception ex)
{
Console.WriteLine($"Profil için hata oluştu: {ex.Message}");
}
}
}
private string[] profileName;
private async Task OpenUrlInChromeProfile(string profileName, CancellationToken token)
{
// ChromeOptions ayarlama
ChromeOptions options = new ChromeOptions();
options.AddArgument($"--user-data-dir={@"C:\Users\fehmi\AppData\Local\Google\Chrome\User Data"}");
options.AddArgument($"--profile-directory={profileName}");
options.AddArgument("--remote-debugging-port=9222"); // Remote debugging portunu ekleyin
// ChromeDriver ile Chrome'u başlat
using (IWebDriver driver = new ChromeDriver(options))
{
try
{
// Tarayıcının tamamen açılmasını bekleyin
await Task.Delay(2000); // 2 saniye bekleme
// YouTube Studio'ya git
driver.Navigate().GoToUrl(youtubeStudioUrl);
MessageBox.Show($"Navigating to {youtubeStudioUrl} for profile {profileName}", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Sayfanın yüklenmesini bekleyin
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until(d => d.Url.Contains("studio.youtube.com"));
MessageBox.Show($"Profil {profileName} için sayfa yüklendi.", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Video yükleme işlemi
await VideoYukle(driver, token);
}
catch (WebDriverException ex)
{
MessageBox.Show($"WebDriver hatası: {ex.Message}", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show($"Genel hata: {ex.Message}", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/790 ... om-c-sharp
Переключайтесь между моими учетными записями Google, используя селен из С# ⇐ C#
Место общения программистов C#
1727374756
Anonymous
Я получаю следующую ошибку: счета открыты, но переход по URL-адресу не выполняется, и транзакции не выполняются. Моя цель — открыть учетные записи, чтобы перейти по URL-адресу и выполнить транзакции.
ждите VideoYukle(драйвер, токен);
функция, можете ли вы предоставить информацию о том, как мне следует редактировать этот код?
/>Было бы здорово, если бы вы предоставили пример кода
// YouTube Studio URL'si
private string youtubeStudioUrl = "https://studio.youtube.com";
// Profil dizinlerini bulur ve her biri için OpenUrlInChromeProfile çağırır
public async Task OpenYouTubeStudiosAsync(CancellationToken token)
{
string userDataPath = @"C:\Users\fehmi\AppData\Local\Google\Chrome\User Data"; // Kullanıcı verileri dizini
string[] profileDirectories = Directory.GetDirectories(userDataPath, "Profile *"); // Tüm profilleri bul
foreach (string profileDir in profileDirectories)
{
if (token.IsCancellationRequested)
break; // Eğer iptal edilmişse döngüyü kır
try
{
string profileName = new DirectoryInfo(profileDir).Name; // Profil adını al
Console.WriteLine($"Profil işleniyor: {profileName}");
// Her profil için YouTube Studio'yu aç
await OpenUrlInChromeProfile(profileName, token);
}
catch (Exception ex)
{
Console.WriteLine($"Profil için hata oluştu: {ex.Message}");
}
}
}
private string[] profileName;
private async Task OpenUrlInChromeProfile(string profileName, CancellationToken token)
{
// ChromeOptions ayarlama
ChromeOptions options = new ChromeOptions();
options.AddArgument($"--user-data-dir={@"C:\Users\fehmi\AppData\Local\Google\Chrome\User Data"}");
options.AddArgument($"--profile-directory={profileName}");
options.AddArgument("--remote-debugging-port=9222"); // Remote debugging portunu ekleyin
// ChromeDriver ile Chrome'u başlat
using (IWebDriver driver = new ChromeDriver(options))
{
try
{
// Tarayıcının tamamen açılmasını bekleyin
await Task.Delay(2000); // 2 saniye bekleme
// YouTube Studio'ya git
driver.Navigate().GoToUrl(youtubeStudioUrl);
MessageBox.Show($"Navigating to {youtubeStudioUrl} for profile {profileName}", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Sayfanın yüklenmesini bekleyin
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
wait.Until(d => d.Url.Contains("studio.youtube.com"));
MessageBox.Show($"Profil {profileName} için sayfa yüklendi.", "Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
// Video yükleme işlemi
await VideoYukle(driver, token);
}
catch (WebDriverException ex)
{
MessageBox.Show($"WebDriver hatası: {ex.Message}", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
MessageBox.Show($"Genel hata: {ex.Message}", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79026638/switch-between-my-google-accounts-using-selenium-from-c-sharp[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия