发送带curl的cookie

发送带curl的cookie

本文介绍了发送带curl的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用curl来检索如下的cookie:

  curl -c cookies.txt url 

然后我从cookies.txt文件解析我想要的cookie,并再次使用cookie发送请求

  curl -bname = valueurl 


b $ b

这是发送cookie的正确方法吗?
有更简单的方法吗?

解决方案

您可以使用-b指定cookie文件来读取cookie



在许多情况下,使用和到同一个文件是您想要的内容:

  curl -b cookies.txt -c cookies.txt http://example.com 



进一步



-c将使curl从没有cookie开始,但仍然解析和理解cookie,如果使用重定向或多个URL,它将使用单个调用中接收的cookie,然后将它们全部写入输出文件到最后。 p>

-b选项将一组初始cookie提供给curl,以便在开始时知道它们,并激活curl的cookie解析器,以便它解析和使用传入的cookie



章。


I am using curl to retrieve cookies like so:

curl -c cookies.txt url

then I parse the cookie I want from the cookies.txt file and send the request again with the cookie

curl -b "name=value" url

Is this the correct way to send the cookie?Is there a simpler way?

解决方案

You can use -b to specify a cookie file to read the cookies from as well.

In many situations using -c and -b to the same file is what you want:

curl -b cookies.txt -c cookies.txt http://example.com

Further

Using only -c will make curl start with no cookies but still parse and understand cookies and if redirects or multiple URLs are used, it will then use the received cookies within the single invoke before it writes them all to the output file in the end.

The -b option feeds a set of initial cookies into curl so that it knows about them at start, and it activates curl's cookie parser so that it'll parse and use incoming cookies as well.

See Also

The cookies chapter in the Everything curl book.

这篇关于发送带curl的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 18:39