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形式的;今天使用时,才发现:
1 |
<font size="3" face="Courier New">Curl has the ability to read and write cookie files that use the same file</font><font size="3"><br /><font face="Courier New"> format that Netscape and Mozilla do</font></font> |