Clearing a cookie when using Twisted and Python
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.
精彩评论