开发者

Clearing a cookie when using Twisted and Python

开发者 https://www.devze.com 2023-04-10 12:34 出处:网络
I am using twisted to fetch a page.For every callback to get a page....is the cookie reset?If not, how do I reset a cookie for every callback?Below is an example...I need a separate cookie for each re

I am using twisted to fetch a page. For every callback to get a page....is the cookie reset? If not, how do I reset a cookie for every callback? Below is an example...I need a separate cookie for each reqest.

client.getPage(iUrl,headers,method='GET',cookies=  {}).addCallback(self.processPage,iUrl).addErrback(self.printError,iUrl)
client.getPage(iUrl,headers,method='GET',c开发者_JS百科ookies=   {}).addCallback(self.processPage,iUrl).addErrback(self.printError,iUrl)
client.getPage(iUrl,headers,method='GET',cookies= {}).addCallback(self.processPage,iUrl).addErrback(self.printError,iUrl)
client.getPage(iUrl,headers,method='GET',cookies= {}).addCallback(self.processPage,iUrl).addErrback(self.printError,iUrl)


Yes. {} creates a new dictionary each time it is evaluated. Each of the 4 calls in your example uses a separate cookies dictionary. No cookies are shared between the requests.

0

精彩评论

暂无评论...
验证码 换一张
取 消