Search code examples
flutterdartflutter-packagesflutter-http

Is there any way to parse html created with javascript in flutter?


I would like to use metadata_fetch package to get the OGP. The implementation of this package uses the html (parse) package. And it worked for most of the web pages. However, there are some web pages, like this one, that cannot be fetched. I think this was because the html was generated by javascript. Is there any way to parse such a page as well?


Solution

  • You should be able to create a webview_flutter and inject some sort of Javascript that would walk the DOM for you and serialize it for return, which of course would happen after the page javascript has already built up the DOM. I haven't done that, but it might be a fun project.

    EDIT: it might be as simple as capturing the string response of document.firstElementChild.outerHTML.