tags:

views:

157

answers:

3

Hi,

does anyone know of a Java library to fetch webpages through https?

+3  A: 

There is a great example of how to fetch a websites contents right in Sun's Java tutorial.

http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html

However if you want to fetch it's entire contents including scripts, images, and other goodies, you will have to parse out the links yourself and download them as well.

John T
Go java.net.URL!
erickson
Does java.net.URL work with HTTPS? I need to authenticate my session before retrieving the page.
Pedro Daniel
Yes it does, and it will throw an exception if the certificate is not trusted. http://java.sun.com/developer/technicalArticles/Security/secureinternet2/
John T
Yes, it does. If you need to do SSL client authentication, you can set the necessary system properties described at http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#InstallationAndCustomization
erickson
+5  A: 

Take a look at HttpClient

Steve Kuo
+3  A: 

As of 1.4, you can use boring old URL.openConnection()...

Neil Coffey