I am writing a web robot and I need for it to identify itself as a robot and not a regular web browser. This should be done by setting the User-Agent, but I can figure out how to do it.
Below is code similar to what I am doing. In the weblog it shows up as 'HTTP/1.1' for the user agent. I want it to say something like '
Java Program, not browser'.
URL url = new URL ("http://www.yahoo.com");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
BufferedReader in = new BufferedReader(
new InputStreamReader
(connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
Thanks
Kevin Nilson