retrofit2-html-converter
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();
}
});