title: How do I enter a url link using jsoup
body: <p>I made 2 simple html pages</p>
  
  <p>page1:</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
   &lt;/head&gt;
   &lt;body&gt;
     &lt;a href="page2.html"&gt;enter page 2&lt;/a&gt;
   &lt;p&gt;
      some data
   &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>page2:</p>
  
  <pre><code>&lt;html&gt;
   &lt;head&gt;
   &lt;/head&gt;
   &lt;body&gt;
     &lt;a href="page1.html"&gt;enter page 1&lt;/a&gt;
     &lt;a href="page3.html"&gt;enter page 3&lt;/a&gt;
   &lt;p&gt;
      some other data
   &lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I want to get the links using jsoup library</p>
  
  <pre><code>Document doc = Jsoup.parse(file, "UTF-8", "http://example.com/"); //file = page1.html
  Element link = doc.select("a").first();
  String absHref = link.attr("href"); // "page2.html/"
  </code></pre>
  
  <p>now what I want to do, is to enter page 2 from page 1(its localy on my computer), and parse it.</p>
  
  <p>I tried to do this:</p>
  
  <pre><code>Document doc2 = Jsoup.connect(absHref).get();
  </code></pre>
  
  <p>But it dosent work, doing me the 404 eror</p>
  
  <p>EDIT:</p>
  
  <p>From a small replay by @JonasCz I tried this: and it is working, I just think there is a better and smarter way.</p>
  
  <pre><code>File file = new File(args[0]);
  String path = file.getParent() + "\\";
  Document doc = Jsoup.parse(file, "UTF-8", "http://example.com/"); //file = page1.html
  Element link = doc.select("a").first();
  String Href = link.attr("href"); // "page2.html/"
  File file2 = new File(path+href);
  Document doc2 = Jsoup.parse(file2, "UTF-8", "http://example.com/");
  </code></pre>
  
  <p>Thank you</p>