简体   繁体   中英

How to pass cookie value as string instead of Map<String, String> in JSOUP?

I wish to pass cookie value found in developer console as string programmatically using Jsoup .

I know below way to pass cookie in JSOUP

.cookies(login.cookies())

the value type is Map<String, String> var1

But I wish to string as below, how to achieve it?

 -H 'Cookie: currency=INR; magnitude=LC; ad=3d468...' \
        -H 'Referer: https://www.valueresearchonline.com/funds/26123/motilal-oswal-flexi-cap-fund-regular-plan/' \

在此处输入图像描述

I guess, you can write your own method to convert from Map<String, String> to String by using StringBuilder.

As you can see on your screenshot, cookies string is sent as a header named Cookie .
If you already have the correct value you can set this header directly:

.header("Cookie", "currency=INR; magnitude=LC; ad=3d4686659c9...")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM