video comment crawl

This commit is contained in:
jason.wang 2024-11-21 20:57:37 +08:00
parent 6432f225e1
commit 7212731971
3 changed files with 3 additions and 17 deletions

View file

@ -47,7 +47,4 @@ public class PageActionArgs
public int WaitTime { get; set; }
public bool ReadInnerHTMLAsBody { get; set; } = false;
public bool IsScrollPage { get; set; } = false;
public int ScrollCount { get; set; } = 1;
public int ScrollWaitTime { get; set; } = 1;
}

View file

@ -77,18 +77,6 @@ public partial class PlaywrightWebDriver
await Task.Delay(args.WaitTime * 1000);
}
if (args.IsScrollPage)
{
var scrollCount = 0;
while (scrollCount < args.ScrollCount)
{
var previousHeight = await page.EvaluateAsync("document.body.scrollHeight");
await page.EvaluateAsync("window.scrollTo(0, document.body.scrollHeight)");
await page.WaitForTimeoutAsync(args.ScrollWaitTime * 1000);
scrollCount++;
};
}
result.ResponseStatusCode = response.Status;
if (response.Status == 200)
{

View file

@ -5,7 +5,8 @@ public partial class PlaywrightWebDriver
public async Task<BrowserActionResult> ScrollPage(MessageInfo message, PageActionArgs args)
{
var result = new BrowserActionResult();
await _instance.Wait(message.ContextId);
var waitTime = args.WaitTime > 0 ? args.WaitTime : 10;
await _instance.Wait(message.ContextId, waitTime, args.WaitForNetworkIdle);
var page = _instance.GetPage(message.ContextId);
@ -31,7 +32,7 @@ public partial class PlaywrightWebDriver
int scrollY = await page.EvaluateAsync<int>("document.body.scrollHeight");
// Scroll to the bottom
await page.Mouse.WheelAsync(0, -scrollY);
await page.Mouse.WheelAsync(0, scrollY);
}
else if (args.Direction == "top")
{