title: Dynamic Link crawl using Retrofit2
body: <p>I am implementing Link preview feature like WhatsApp, i.e</p>
  
  <ol>
  <li>Provided any link, fetch all its Html</li>
  <li>Crawl through Html, read all information</li>
  <li>Display text and images</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/2m3li.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2m3li.jpg" alt="WhatsApp Link Preview"></a></p>
  
  <h2><strong>Jsoup Library</strong></h2>
  
  <p>I am successfully able to perform this using Jsoup library</p>
  
  <pre><code>Document doc = Jsoup.connect("http://www.techjuice.pk").userAgent("Mozilla").get();
  </code></pre>
  
  <p>It returns the html code of the page as a response.</p>
  
  <hr>
  
  <h2><strong>Retrofit Library</strong></h2>
  
  <p>Now I wanted to perform the same task using Retrofit</p>
  
  <pre><code>Retrofit retrofit = new Retrofit.Builder()
                      .build();
  API api = retrofit.create(API.class);
  Call&lt;ResponseBody&gt; call = api.crawlLink("http://techjuice.pk");
  call.enqueue(new Callback&lt;ResponseBody&gt;() {
      @Override
      public void onResponse(Call&lt;ResponseBody&gt; call, Response&lt;ResponseBody&gt; response) {
      }
  
      @Override
      public void onFailure(Call&lt;ResponseBody&gt; call, Throwable t) {
      }
  });
  </code></pre>
  
  <p><strong>API.class</strong></p>
  
  <pre><code>public interface API {
  
      @GET
      Call&lt;ResponseBody&gt; crawlLink(@Url String url);
  
  }
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Base URL required.</p>
  </blockquote>