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.se
its work for me set the User-Agent in the addRequestProperty.
URL url = new URL(); HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); httpConn.addRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0");