Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support html output from the library #2

Closed
derekperkins opened this issue Mar 9, 2023 · 1 comment
Closed

support html output from the library #2

derekperkins opened this issue Mar 9, 2023 · 1 comment

Comments

@derekperkins
Copy link

It would be nice if there was a library method for outputting the html nodes from the library, similar to how it is done in the cli, which is difficult to copy since it references internal functions.
https://github.com/markusmobius/go-trafilatura/blob/main/cmd/go-trafilatura/output.go#L81-L147

@RadhiFadlillah
Copy link
Collaborator

In the latest version there is a helper function named CreateReadableDocument which expose that functionality. So now you can use it like this:

result, _ := trafilatura.Extract(r, opts)
readableDoc := trafilatura.CreateReadableDocument(result)

// To print the HTML output, you can use it with go-shiori/dom package
fmt.Println(dom.OuterHTML(readableDoc))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants