Вот мой код:
Если вы можете предоставить мне или направьте меня правильным путем, очень ценю это:
Код: Выделить всё
using System;
using System.Threading.Tasks;
using PuppeteerSharp;
namespace SOYoutube
{
class Program
{
static async Task Main(string[] args)
{
// Define the URL of the question
string questionUrl = "www.youtube.com";
// Download the Chromium revision if not already done
var browserFetcher = new BrowserFetcher();
await browserFetcher.DownloadAsync();
// Launch a new browser instance
await using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = false // Set to true if you want to run in headless mode
});
// Open a new page
await using var page = await browser.NewPageAsync();
// Navigate to the question page
await page.GoToAsync(questionUrl);
// Wait for the upvote button to be present in the DOM
await page.WaitForSelectorAsync("");
// Click the upvote button
await page.ClickAsync("");
// Keep the browser open for a while to observe the action
await Task.Delay(5000);
// Close the browser
await browser.CloseAsync();
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -puppeteer