Why am i getting 403 error reading a website url on java?
<p>I'm trying to read <a href="http://www.meuhumor.com.br/" rel="nofollow">http://www.meuhumor.com.br/</a> on java using this:</p>

<pre><code>URL url;
        HttpURLConnection connection = null;        
        try{
            url = new URL(targetURL);
            connection = (HttpURLConnection)url.openConnection();

            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            connection.setRequestProperty("Content-Language", "en-US"); 
            connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11");
            connection.setUseCaches(false);
            connection.setDoInput(true);
            connection.setDoOutput(true);

            DataOutputStream dataout = new DataOutputStream(connection.getOutputStream());
            dataout.flush();
            dataout.close();

            InputStream is = connection.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            String line;
            StringBuffer response = new StringBuffer();

            while((line = br.readLine()) != null){
                response.append(line);
                response.append('\n');
            }
            br.close();
            String html = response.toString();
</code></pre>

<p>I can access the website using any browser, but when i try to get the html with Java im getting java.io.IOException: Server returned HTTP response code: 403 for URL:</p>

<p>Someone know a way to get the html?</p>
