Skip to content

Commit

Permalink
v8.2024.1016.1336
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed Oct 16, 2024
1 parent 3ed0221 commit e094640
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
31 changes: 23 additions & 8 deletions src/NetPackageAnalyzer/NPA.HtmlData/ExtractImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,37 @@ public async Task<bool> GetImagesAsync()
var page = await context.NewPageAsync();
//await page.SetContentAsync(File.ReadAllText(HtmlPath));
var resp= await page.GotoAsync(new Uri(HtmlPath).AbsoluteUri);
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await Task.Delay(5000);
try
{
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
}
catch (Exception ex)
{
Console.WriteLine("error in wait for load state network idle "+ex.Message);
}
await page.EvaluateAsync("driverObj.destroy()");
var titles = await page.Locator("//div[starts-with(@title,'image')]").AllAsync();
var nr = titles.Count();
//Console.WriteLine($"Found {nr} images");
for (var i = 0; i < nr; i++)
{
var title = titles[i];
var name=await title.GetAttributeAsync("title");
if(string.IsNullOrWhiteSpace(name))
var name = await title.GetAttributeAsync("title");
if (string.IsNullOrWhiteSpace(name))
continue;
name =name.Replace("image", "").Trim();
name = name.Replace(" ", "-");
var buffer = await title.ScreenshotAsync();

await File.WriteAllBytesAsync(Path.Combine(imagesDir, $"{name}.png"), buffer);
var newName = name.Replace("image", "").Trim();
newName = newName.Replace(" ", "-");
try
{
var buffer = await title.ScreenshotAsync();

await File.WriteAllBytesAsync(Path.Combine(imagesDir, $"{newName}.png"), buffer);
}
catch(Exception ex)
{
Console.WriteLine($"Error in screenshot {name} " + ex.Message);
}
}
await browser.CloseAsync();
//Console.WriteLine("Done in "+dir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<ProjectReference Include="..\NetPackageAnalyzerWork\NetPackageAnalyzerDocusaurus.csproj" />
</ItemGroup>
<PropertyGroup>
<Version>8.2024.1015.1904</Version>
<Version>8.2024.1016.1336</Version>
<PackAsTool>true</PackAsTool>
<ToolCommandName>PackageAnalyzer</ToolCommandName>
<Authors>Andrei Ignat</Authors>
Expand Down

0 comments on commit e094640

Please sign in to comment.