我创建了一个小应用程序,它应该从 Internet trought 获取一些数据Puppeteer Sharp
,问题是在我实例化浏览器后,软件冻结而没有错误。
public partial class MainWindow : Window
{
public Handler Handler { get; } = new Handler();
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Handler.Init(Handler).Wait();
}
}
如您所见,我拥有Handler
该软件的所有属性:
public class Handler
{
private static Url URL = new Url("https://www.diretta.it/");
public static Browser Browser { get; set; }
public async Task<bool> Init(Handler prop)
{
DotNetEnv.Env.Load("./config.env");
// The problem's here
Browser = await Puppeteer.LaunchAsync(new LaunchOptions
{
Headless = true,
ExecutablePath = Environment.GetEnvironmentVariable("CHROME_PATH"),
});
return true;
}
}
这是哪里CHROME_PATH
:CHROME_PATH="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
我做错了什么?我也有最新版本的Chrome
and PuppeteerSharp
。