Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extracting data from web page (table etc); will HtmlDoc be included in LA?
#17
Try Selenium. It is more reliable for web browser automation. For example can reliably wait until web page loaded. But not so easy to use, and will need to install 2 NuGet packages and update them for each new Chrome version.
 
Code:
Copy      Help
// script ""
/*/ nuget selenium\Selenium.Support; nuget selenium\Selenium.WebDriver.ChromeDriver; /*/
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Support.Extensions;
using OpenQA.Selenium.Support.UI;
script.setup(trayIcon: true, sleepExit: true, exitKey: KKey.MediaStop, pauseKey: KKey.MediaPlayPause);
print.clear();

//Starts new Chrome instance.

ChromeOptions options = new();
//Enable and maybe edit this if want to use an existing profile. To get profile path, in Chrome open URL "chrome://version/".
//    Then before starting this script also may need to close existing Chrome instances that use this profile.
//options.AddArguments($"user-data-dir={folders.LocalAppData + @"Google\Chrome\User Data"}", "profile-directory=Profile 1");


var service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
using var driver = new ChromeDriver(service, options);
driver.Manage().Window.Maximize();

for (int i = 1; i <= 5; i++) {
    script.pause();
    driver.Navigate().GoToUrl($"https://filecr.com/ms-windows/?page={i}"); //opens and waits until loaded
    1.s();
}


1.s();
dialog.show("Close web browser", x: ^1);



The same way can be used without Selenium, but I cannot find a reliable way to wait until web page loaded, therefore will need to add delays and it makes the script slower.


Messages In This Thread
RE: Will HtmlDoc be included in LA? - by Gintaras - 05-14-2023, 07:34 AM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-14-2023, 12:10 PM
RE: Will HtmlDoc be included in LA? - by Gintaras - 05-14-2023, 12:31 PM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-14-2023, 12:44 PM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-20-2023, 02:58 PM
RE: Will HtmlDoc be included in LA? - by Gintaras - 05-20-2023, 04:07 PM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-20-2023, 04:27 PM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-27-2023, 06:18 AM
RE: Will HtmlDoc be included in LA? - by Gintaras - 05-27-2023, 07:16 AM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-27-2023, 07:23 AM
RE: Will HtmlDoc be included in LA? - by birdywen - 05-31-2023, 03:13 AM
RE: Will HtmlDoc be included in LA? - by Gintaras - 05-31-2023, 04:05 AM
RE: Will HtmlDoc be included in LA? - by Gintaras - 05-31-2023, 04:25 AM
RE: Extracting data from web page (table etc); will HtmlDoc be included in LA? - by Gintaras - 06-01-2023, 07:23 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)