Setting user agent of a java URLConnection
Posted
by diglettpotato
on Stack Overflow
See other posts from Stack Overflow
or by diglettpotato
Published on 2010-03-27T14:46:52Z
Indexed on
2010/03/27
14:53 UTC
Read the original article
Hit count: 436
user-agent
|java
I'm trying to parse a webpage using Java with URLConnection. I try to set up the user-agent like this:
java.net.URLConnection c = url.openConnection();
c.setRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2");
But the resulting user agent is the one I specify, with "Java/1.5.0_19" appended to the end. Is there a way to truly set the user agent without this addition?
© Stack Overflow or respective owner