RetrofitHtmlConverter

Converter implementation for retrofit 2 using jsoup

License

License

Categories

Categories

Retrofit Net HTTP Clients
GroupId

GroupId

com.github.slashrootv200
ArtifactId

ArtifactId

retrofit-html-converter
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

RetrofitHtmlConverter
Converter implementation for retrofit 2 using jsoup
Project URL

Project URL

https://github.com/slashrootv200/retrofit2-html-converter
Source Code Management

Source Code Management

https://github.com/slashrootv200/retrofit2-html-converter

Download retrofit-html-converter

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.slashrootv200/retrofit-html-converter/ -->
<dependency>
    <groupId>com.github.slashrootv200</groupId>
    <artifactId>retrofit-html-converter</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.slashrootv200/retrofit-html-converter/
implementation 'com.github.slashrootv200:retrofit-html-converter:0.0.1'
// https://jarcasting.com/artifacts/com.github.slashrootv200/retrofit-html-converter/
implementation ("com.github.slashrootv200:retrofit-html-converter:0.0.1")
'com.github.slashrootv200:retrofit-html-converter:jar:0.0.1'
<dependency org="com.github.slashrootv200" name="retrofit-html-converter" rev="0.0.1">
  <artifact name="retrofit-html-converter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.slashrootv200', module='retrofit-html-converter', version='0.0.1')
)
libraryDependencies += "com.github.slashrootv200" % "retrofit-html-converter" % "0.0.1"
[com.github.slashrootv200/retrofit-html-converter "0.0.1"]

Dependencies

compile (2)

Group / Artifact Type Version
com.squareup.retrofit2 : retrofit jar 2.3.0
org.jsoup : jsoup jar 1.10.3

Project Modules

There are no modules declared in this project.

retrofit2-html-converter

Download

Download

maven

<dependency>
  <groupId>com.github.slashrootv200</groupId>
  <artifactId>retrofit-html-converter</artifactId>
  <version>0.0.2</version>
  <type>pom</type>
</dependency>

gradle

compile 'com.github.slashrootv200:retrofit-html-converter:0.0.2'

Usage

Service

public interface CollectionsJavaDocWebPageService {
  @GET("javase/7/docs/api/java/util/Collections.html")
  Call<Document> fetch();
}

Add converter to the RetrofitBuilder

Retrofit retrofit = new Retrofit.Builder().baseUrl(baseUrl)
  .addConverterFactory(HtmlConverterFactory.create(baseUrl))
  .build();
CollectionsJavaDocWebPageService service
                      = retrofit.create(CollectionsJavaDocWebPageService.class);
Call<Document> call = service.fetch();

Get Document as a response object

import org.jsoup.nodes.Document;

call.enqueue(new Callback<Document>() {
  @Override
  public void onResponse(Call<Document> call, Response<Document> response) {
    Document document = response.body();
    document.setBaseUri(base);
    String html = document.html(); 
    // contains the html of https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html
  }

  @Override
  public void onFailure(Call<Document> call, Throwable t) {
    t.printStackTrace();
   }
});

Versions

Version
0.0.1