Skip to content

📃 Generate a single HTML file for a given URL by transforming external assets (css, js, images, fonts) into inline content and by encoding them with base64 if necessary. Java 1.7 and Android compatible.

License

alimogh/webpage2html-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

webpage2html-java

Generate a single HTML file for a given URL by transforming external assets (css, js, images, fonts) into inline content and by encoding them with base64 if necessary.

Initially a Java port of zTrix/webpage2html.

Java 1.7 and Android compatible. Still in early development.

Known limitations

Dependencies

Usage

// Build a WebPage2Html object from a java.net.URL object
URL url = new URL("http://rtw.cedricblondeau.com"); // Input URL, throws MalformedURLException
WebPage2Html webPage2Html = new WebPage2Html(url);

// Optionally: Pass a custom configuration object
Configuration configuration = new Configuration();
configuration.setUserAgent("Android"); // Custom user-agent
webPage2Html.setConfiguration(configuration);

// execute() method returns a WebPage2HtmlResult object
WebPage2HtmlResult webPage2HtmlResult = webPage2Html.execute(); // throws IOException
webPage2HtmlResult.getUrl();    // Actual URL, could be different from input URL (e.g. redirection)
webPage2HtmlResult.getTitle();  // HTML document title
webPage2HtmlResult.getHtml();   // Transformed HTML content

CLI usage using Gradle

./gradlew run -Dexec.args="http://rtw.cedricblondeau.com out.html"

About

📃 Generate a single HTML file for a given URL by transforming external assets (css, js, images, fonts) into inline content and by encoding them with base64 if necessary. Java 1.7 and Android compatible.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%