Giter Site home page Giter Site logo

Comments (3)

JonathanMagnan avatar JonathanMagnan commented on September 26, 2024 1

Hello @pycxu ,

I would recommend you create your own extension methods. So your could use it this way:

node.GetAttributeValue("style", "").GetComputedStyle("left");

You pretty much already have the code you want for this method.

I do not believe at this moment we will add it on our side.

Best Regards,

Jon


Sponsorship
Help us improve this library

Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework ExtensionsDapper Plus

Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval Function

from html-agility-pack.

elgonzo avatar elgonzo commented on September 26, 2024 1

Just an FYI: Using the function name GetComputedStyle here is likely misleading. Getting a computed style properly is not simply done by parsing the source HTML document and extracting the style values from the "style" attribute. To get actual computed styles would require more or less a layout engine plus possibly a Javascript engine, something that is well beyond a "simple" HTML parser.

If you would really need computed style properties of an element in your HTML document (emphasis on "computed"), the best approach would be probably using a head-less browser engine, something like CEF (for which there is also a .NET wrapper: CefSharp)

from html-agility-pack.

pycxu avatar pycxu commented on September 26, 2024

Just an FYI: Using the function name GetComputedStyle here is likely misleading. Getting a computed style properly is not simply done by parsing the source HTML document and extracting the style values from the "style" attribute. To get actual computed styles would require more or less a layout engine plus possibly a Javascript engine, something that is well beyond a "simple" HTML parser.

If you would really need computed style properties of an element in your HTML document (emphasis on "computed"), the best approach would be probably using a head-less browser engine, something like CEF (for which there is also a .NET wrapper: CefSharp)

Thanks for the heads up. That makes so much sense. I will do that with Puppeteer Sharp.

from html-agility-pack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.