google spreadsheet csv redirect problem

302 Moved Temporarily
# wget https://spreadsheets.google.com/spreadsheet/ccc?hl=en&key=t4yQsQxDLW4EsD7wX_aKHPw&output=csv
[1] 17658
[2] 17659
# --2011-07-23 14:55:08--  https://spreadsheets.google.com/spreadsheet/ccc?hl=en
Resolving spreadsheets.google.com (spreadsheets.google.com)... 74.125.235.100, 74.125.235.97, 74.125.235.102, ...
Connecting to spreadsheets.google.com (spreadsheets.google.com)|74.125.235.100|:443... connected.
ERROR: cannot verify spreadsheets.google.com's certificate, issued by `/C=US/O=Google Inc/CN=Google Internet Authority':
  Unable to locally verify the issuer's authority.
To connect to spreadsheets.google.com insecurely, use `--no-check-certificate'.

[1]-  Exit 5                  wget https://spreadsheets.google.com/spreadsheet/ccc?hl=en
[2]+  Done                    key=t4yQsQxDLW4EsD7wX_aKHPw
URL u = new URL("https://spreadsheets.google.com/spreadsheet/ccc?hl=en&key=t4yQsQxDLW4EsD7wX_aKHPw&output=csv");
u.openStream();

Solution

Running codes
pom.xml http://bazaar.launchpad.net/~ryoji-kodakari/pisclex/pe/view/head:/pom.xml
java http://bazaar.launchpad.net/~ryoji-kodakari/pisclex/pe/view/head:/src/main/java/pisclex/texteditor/autocomplecion/Editor.java

HttpClient + HttpGet

pom.xml

		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.1.1</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
        final HttpClient hc = new DefaultHttpClient();
        final HttpGet hg = new HttpGet("https://spreadsheets.google.com/spreadsheet/ccc?hl=en&key=t4yQsQxDLW4EsD7wX_aKHPw&output=csv");
        FileOutputStream out;
        try
        {
            out = new FileOutputStream("data" + File.separator + "/Pisclex Dicciones.csv");
            final HttpResponse response = hc.execute(hg);
            final HttpEntity entity = response.getEntity();
            if (entity != null)
            {
                final InputStream instream = entity.getContent();
                int l;
                final byte[] tmp = new byte[2048];
                while ((l = instream.read(tmp)) != -1)
                {
                    out.write(tmp, 0, l);
                }
            }
        }
        catch (final ClientProtocolException e1)
        {
            e1.printStackTrace();
        }
        catch (final FileNotFoundException e)
        {
            e.printStackTrace();
        }
        catch (final IOException e1)
        {
            e1.printStackTrace();
        }

ok.

    last modified: 23 July 2011 [ View wiki source Close ]
     
SEARCH DIFFERENCE ATTACHMENT RECENT POST