Connecting to a URL

Hey. Im trying to connect to an URL and read back the contents to a file...

i can read to a url fine, www.google.com for example. but when i try to read back something like http://www.google.co.uk/search?&q=example

then i get a 403 error and my code fails.

URL google =new URL("http://www.google.co.uk/search?hl=en&safe=off&q=apple&meta=");

URLConnection gc = google.openConnection();

im guessing its something to do with the fact that im posting a variable to the server and need to wait for the response, any help would be great.

[632 byte] By [Notinoa] at [2007-11-26 16:50:25]
# 1
A hint: Google does not like to respond to robots.
BIJ001a at 2007-7-8 23:18:03 > top of Java-index,Core,Core APIs...
# 2

hm...so is this possible? a bit more would be great :)

what i need to do is append search?q=search string

to the end of my URL connection, but as you said google doesnt like robots. so how do i go around this? POST it?

do i need to set my useragent as IE for example?

Message was edited by:

Notino

Message was edited by:

Notino

Notinoa at 2007-7-8 23:18:03 > top of Java-index,Core,Core APIs...
# 3
maybe you can try URL myUrl = new URL(AURL);URLConnection myConn = (HttpURLConnection)myUrl.openConnection();myConn.setRequestProperty("User-agent","Mozilla/4.0");BufferedReader br = new BufferedReader(new InputStreamReader(myConn.getInputStream()));
RobertSnooga at 2007-7-8 23:18:03 > top of Java-index,Core,Core APIs...
# 4
thanks, worked fine!
Notinoa at 2007-7-8 23:18:03 > top of Java-index,Core,Core APIs...