AngleSharp / AngleSharp.Js

:angel: Extends AngleSharp with a .NET-based JavaScript engine.
https://anglesharp.github.io
MIT License
103 stars 22 forks source link

How to execute simple Javascript? #69

Closed BrianAllred closed 4 years ago

BrianAllred commented 4 years ago

I've got the document loaded and I only need to execute a single line of JS, but I can't find any trivial examples.

FlorianRappl commented 4 years ago

Not sure how this is a bug. For questions please use StackOverflow or specify exactly what you tried and what failed.

The README shows a couple of ways how this can be used.

For instance, the following is contained in there, which looks like a match according to the given information:

var config = Configuration.Default.WithJs();
var context = BrowsingContext.New(config);
var document = await context.OpenAsync(address).WaitUntilAvailable();
var numEntries = document.ExecuteScript("document.querySelectorAll('div').length");

Hope that helps!