If you "Data Mine" using tools such as Web-Harvester or others that are Java Based, it is difficult to get in the front door of many sites because your user-agent string says something like this:
Java/1.6.0-rc
This is immediately detected and you are refused. Unfortuantly if you attempt to change this via the URLConnection objects properties, it does not work properly.
I have found that following, using Apache's HTTPClient class to do the trick:
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
public class getter {
public final static void main(String[] args) throws Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
BasicHttpParams hp = new BasicHttpParams();
hp.setParameter("http.useragent", (Object)"Mozilla/1.0 (compatible; linux 2015 plus; yep)"); // you oughta change this into your own UA string....
httpclient.setParams(hp);
try {
HttpGet httpget = new HttpGet("http://zminer.com/");
ResponseHandler responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);
System.out.println(responseBody);
} finally {
httpclient.getConnectionManager().shutdown();
}
}
}
You will find that this can set the user-agent name.
I am interested in knowing if anyone else has run into this issue, or has solved it in a different way...
Thanks.
-DTM
Java/1.6.0-rc
This is immediately detected and you are refused. Unfortuantly if you attempt to change this via the URLConnection objects properties, it does not work properly.
I have found that following, using Apache's HTTPClient class to do the trick:
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
public class getter {
public final static void main(String[] args) throws Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
BasicHttpParams hp = new BasicHttpParams();
hp.setParameter("http.useragent", (Object)"Mozilla/1.0 (compatible; linux 2015 plus; yep)"); // you oughta change this into your own UA string....
httpclient.setParams(hp);
try {
HttpGet httpget = new HttpGet("http://zminer.com/");
ResponseHandler responseHandler = new BasicResponseHandler();
String responseBody = httpclient.execute(httpget, responseHandler);
System.out.println(responseBody);
} finally {
httpclient.getConnectionManager().shutdown();
}
}
}
You will find that this can set the user-agent name.
I am interested in knowing if anyone else has run into this issue, or has solved it in a different way...
Thanks.
-DTM