1) Modify the java.net.URL class to send a user agent (I assume you
can still get the source code to that class - I know I got it
when I was doing Java Development - got it straight from Sun for
no money).
2) Write the code to actually connect to the web server yourself.
I did 2. I still used the URL class, but only for parsing the actual URL
for me. I then did:
public Socket makeConnection(URL cgiurl)
{
String host = cgiurl.getHost();
int port = cgiurl.getPort();
String prot = cgiurl.getProtocol();
Socket sock = new Socket(host,port);
return(sock);
}
And in another function:
public boid standardHeaders(DataOutputStream dos) throws IOException
{
dos.writeBytes(
EngineConst.Referer
+ EngineConst.UserAgent
+ EngineConst.Host()
+ EngineConst.Accept
);
}
Where I have the following:
public final class EngineConst
{
public final static String Referer = "Referer:http://www.cyber411.com\r\n";
public final static String UserAgent = "User-agent: C4 Java/0.9.1J\r\n";
public final static STring Accept = "Accept: text/html\r\n";
public final static String Host()
{
return((InetAddress.getLocalHost()).toString());
}
}
I've left out quite a bit of details here (mostly due to error detection)
but you get the idea.
-spc (Have fun ... )
_________________________________________________
This messages was sent by the robots mailing list. To unsubscribe, send mail
to robots-request@webcrawler.com with the word "unsubscribe" in the body.
For more info see http://info.webcrawler.com/mak/projects/robots/robots.html