[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: overrider or append entries in cookie file with --header "cookie: xx
From: |
Tim Rühsen |
Subject: |
Re: overrider or append entries in cookie file with --header "cookie: xxx"? |
Date: |
Sat, 15 Feb 2020 19:51:14 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 |
No, wget won't override a cookie from cookies.txt with -H.
That's when shell scripting comes into play.
E.g. pipe your cookies.txt through grep -v or sed to remove a certain
line (or several lines) and save it temporarily in e.g. cookies2.txt.
Then run wget with cookies2.txt. After that, either keep the old, the
new or a combination of the files.
Regards, Tim
On 15.02.20 18:46, Peng Yu wrote:
> Hi,
>
> I have a cookie file. I'd like to override an entity in it or specific
> an extra cookie entry with -H.
>
> But it seems that wget just ignore what is in the cookie file if -H
> "cookie: xxx" is specified. Is there a way to override entries in the
> cookie file? Thanks.
>
>
> $ wget --load-cookies cookie.txt --keep-session-cookies --save-cookies
> cookie.txt -qO- -o /dev/null 'http://httpbin.org/cookies/set?A=1'
> {
> "cookies": {
> "A": "1"
> }
> }
> $ cat cookie.txt
> # HTTP cookie file.
> # Generated by Wget on 2020-02-15 11:44:52.
> # Edit at your own risk.
>
> httpbin.org FALSE / FALSE 0 A 1
> $ wget --load-cookies cookie.txt --keep-session-cookies --save-cookies
> cookie.txt -qO- -o /dev/null http://httpbin.org/cookies
> {
> "cookies": {
> "A": "1"
> }
> }
> $ cat cookie.txt
> # HTTP cookie file.
> # Generated by Wget on 2020-02-15 11:44:53.
> # Edit at your own risk.
>
> httpbin.org FALSE / FALSE 0 A 1
> $ wget --header 'cookie: B=2' --load-cookies cookie.txt
> --keep-session-cookies --save-cookies cookie.txt -qO- -o /dev/null
> http://httpbin.org/cookies
> {
> "cookies": {
> "B": "2"
> }
> }
> $ cat cookie.txt
> # HTTP cookie file.
> # Generated by Wget on 2020-02-15 11:44:53.
> # Edit at your own risk.
>
> httpbin.org FALSE / FALSE 0 A 1
> $ rm cookie.txt
>
>
signature.asc
Description: OpenPGP digital signature