View Single Post
  #11 (permalink)  
Old 04-08-2008, 12:39 PM
DonCash's Avatar
DonCash DonCash is offline
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 240
DonCash will become famous soon enoughDonCash will become famous soon enough
Hey aibtus - Here is a full code example:

Code:
import java.net.*; import java.io.*; class httpconnect { public static void main(String[] args) throws Exception { URL url = new URL("http://www.google.co.uk/"); URLConnection spoof = url.openConnection(); spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" ); BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream())); String strLine = ""; while ((strLine = in.readLine()) != null) { System.out.println(strLine); } in.close(); } }
Note the extra bit of code:

Code:
spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" );
Websites like Google block connections to their site from programs other than web browsers. With this bit of code you can trick sites like these into thinking the connection is coming from a web browser. Very handy!

If you wish to surf through a proxy server then you can also add this code to the top:

Code:
System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyPort", "80"); System.getProperties().put("proxyHost", "my.proxyserver.co.uk");
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote