title: How to correctly parse HTML in Java
body: <p>I'm trying to extract information from websites using Jsoup but I don't get the same HTML code as in my browser. </p>
  
  <p>I tried to use <code>.userAgent()</code> but it didn't work. I currently use the following function wich works for Amazon.com :</p>
  
  <pre><code>public static String getHTML(String urlToRead) throws Exception {
        StringBuilder result = new StringBuilder();
        URL url = new URL(urlToRead);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0");
        conn.setRequestMethod("GET");
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
        String line;
        while ((line = rd.readLine()) != null) {
           result.append(line);
        }
        rd.close();
        return result.toString();
     }
  </code></pre>
  
  <p>The website I'm trying to parse is <a href="http://www.asos.com/" rel="nofollow noreferrer">http://www.asos.com/</a> but the price of the product is always missing.</p>
  
  <p>I fond <a href="https://stackoverflow.com/questions/43316227/why-html-code-is-different-when-parsing-site-using-jsoup-than-using-browser">this topic</a> which is pretty close to mine but I would like to do it using only java and no external app.</p>