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