AngleSharp / AngleSharp.Js

:angel: Extends AngleSharp with a .NET-based JavaScript engine.

Home Page:https://anglesharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to run JavaScript

ShivrajY opened this issue · comments

Bug Report

Prerequisites

  • [ x] Can you reproduce the problem in a MWE?
  • [ x] Are you running the latest version of AngleSharp?
  • [ x] Did you check the FAQs to see if that helps you?
  • [x ] Are you reporting to the correct repository? (there are multiple AngleSharp libraries, e.g., AngleSharp.Css for CSS support)
  • [ x] Did you perform a search in the issues?

Description

AngleSharp couldn't parse Javascript. Page shows "You need to enable JavaScript to run this app."

Steps to Reproduce

using AngleSharp;
using AngleSharp.Js;
using AngleSharp.Io;
using AngleSharp.Dom;
using AngleSharp.Css;

var r = new DefaultHttpRequester("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:100.0) Gecko/20100101 Firefox/100.0", req =>
            {
                req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8";
                req.AutomaticDecompression = System.Net.DecompressionMethods.All;
                req.CookieContainer = new System.Net.CookieContainer();
                req.AllowAutoRedirect = true;
            });

var config = Configuration.Default
    .WithEventLoop()
    .WithJs()
    .WithRequester(r)
    .WithDefaultLoader(new LoaderOptions { IsResourceLoadingEnabled = true })
    .WithCss();


var context = BrowsingContext.New(config);

var url = "https://aperturedata.io/";

var doc = await context.OpenAsync(url).WaitUntilAvailable();

var html = doc.ToHtml();
Console.WriteLine(html);
var x = html?.ToLowerInvariant().Contains("contact");
Console.WriteLine(x);

Expected behavior: [What you expected to happen]
It should show true, as word "Contact" is present in the Dom text.

Actual behavior: [What actually happened]
Didn't run JavaScript.

Environment details: [OS, .NET Runtime, ...]
.Net 6.0, Macbook M1 Pro

Possible Solution

Like to see workaround like manually calling javascript function using AngleSharp
[Optionally, share your idea to fix the issue]