Android user agent in URLConnection
<p>I'm trying to "fool" Google Finance into thinking I'm a web browser by changing the user agent property in my connection. However, the response I get back still isn't what I should get when I use an actual web browser. I was wondering why this is, and what I need to do in order for it to work? Here is the relevant code (the "site" is <a href="https://www.google.co.uk/finance/converter?a=1&amp;from=GBP&amp;to=USD" rel="nofollow">https://www.google.co.uk/finance/converter?a=1&amp;from=GBP&amp;to=USD</a>):</p>

<pre><code>protected static String readURL(String site) {
    StringBuilder buff = new StringBuilder();
    try {
        HttpURLConnection conn = (HttpURLConnection) new URL(site).openConnection();
        conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393");
        conn.connect();
        BufferedReader bfr = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String inputLine;
        while ((inputLine = bfr.readLine()) != null)
            buff.append(inputLine).append('\n');
        bfr.close();
    }
    catch (Exception ioe) {
        System.err.println("Failed to read from \""+site+"\": "+ioe.getMessage());
    }
    return buff.toString();
}
</code></pre>

<p>EDIT: I should note that this is in an Android application, not a Java one. It is also not displayed to the user in a WebView or anything, this happens in the background.</p>