Home » Java » UserAgent in JSOUP?

UserAgent in JSOUP?

Posted by: admin December 28, 2021 Leave a comment

Questions:

I have always seen everywhere in JSOUP code.

Useragent is set to Mozilla .

What if i want to set it to google chrome or opera?

Jsoup.connect(url)
      .userAgent("Mozilla");

How i can achieve this?
Thanks in advance.

Answers:

go there :

http://www.useragentstring.com/pages/Opera/
or
http://www.useragentstring.com/pages/Chrome/

and get the one you like.

for example:

Jsoup.connect(url).userAgent("Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52");