curl 命令使用cookie

curl -c cookie.txt www.baidu.com
cat cookie.txt
# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

.baidu.com      TRUE    /       FALSE   4294967295      BAIDUID F12E0E84A1A44C56325C9FB70263B8B7:FG=1

[root@bsso software-rpm]# curl -b cookie.txt baidu.com -v
* About to connect() to baidu.com port 80
*   Trying 220.181.6.182… * connected
* Connected to baidu.com (220.181.6.182) port 80
> GET / HTTP/1.1
User-Agent: curl/7.12.1 (i686-redhat-linux-gnu) libcurl/7.12.1 OpenSSL/0.9.7a zlib/1.2.1.2 libidn/0.5.6
Host: baidu.com
Pragma: no-cache
Accept: */*
Cookie: BAIDUID=F12E0E84A1A44C56325C9FB70263B8B7:FG=1

这里旨在提醒一下cookie文件的格式,以前一直以为是name=value形式的;今天使用时,才发现:

留下评论

邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据