JSoup Connection.userAgent defeated by sun.net.www.protocol.http.HttpURLConnection

Apparently sun.net.www.protocol.http.HttpURLConnection always adds "Java / version" to UserAgent. Therefore JSoup Connection.userAgent cannot configure useragent to do what you want; Java / version stuff is added anyway.

See Set user-agent property in https connection header

Some websites reject requests containing "Java" anywhere user agent providing various HTTP 4xx and 5xx errors.

The StackOverflow post mentioned above suggests using Apache instead of Sun's HTTP connection, but that's not an option if I want to use JSoup.

I wonder what the JSoup team thinks about this. Is my description correct? Is this a bug or a feature? Are there any plans to fix it i.e. To set userAgent to whatever you want without additional appendages?

thank you ORG

+3


source to share


1 answer


You can use Jsoup.parse (html) where the html String can be retrieved using Apache HTTP or any other library of your choice. Regards, Allahbaksh



0


source







All Articles