Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python上创建.ASPXAUTH cookie_Python_Http Headers - Fatal编程技术网

如何在python上创建.ASPXAUTH cookie

如何在python上创建.ASPXAUTH cookie,python,http-headers,Python,Http Headers,我需要在python上创建.ASPXAUTH cookie。我正在编程到桌面客户端。第一个请求不需要.ASPXAUTH cookie,但第二个请求需要 我的第一个请求标题: User-Agent: WebPolicy Host: xxx.host Cache-Control: no-cache 我的第一个响应标题: reply: 'HTTP/1.1 200 OK\r\n' header: Cache-Control: private header: Transfer-Encoding: ch

我需要在python上创建.ASPXAUTH cookie。我正在编程到桌面客户端。第一个请求不需要.ASPXAUTH cookie,但第二个请求需要

我的第一个请求标题:

User-Agent: WebPolicy
Host: xxx.host
Cache-Control: no-cache
我的第一个响应标题:

reply: 'HTTP/1.1 200 OK\r\n'
header: Cache-Control: private

header: Transfer-Encoding: chunked

header: Content-Type: text/xml; charset=utf-8

header: Server: Microsoft-IIS/7.5

header: Set-Cookie: tivi_=3tnihi55ezuk50zyrrpuwv45; path=/; HttpOnly

header: X-AspNet-Version: 2.0.50727

header: X-Powered-By: ASP.NET

header: Date: Thu, 14 Oct 2010 13:05:50 GMT
我需要第二个发送头:

Accept: */*
Content-Length: 259
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/IMiddlewareServices/Login"
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322)
Host: mw.webtv.ttnet.com.tr
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: .ASPXAUTH=090F2718E32AF3F9B1C9E5A15BA54CFD8D4430C44A91029719953D4A6D38DD1D9164D86D772E2645C0C0545A71C12EA80AE5A8F725FD6037BD00DB291A863DD577735E16D8745E2833979F337935F29A37C509FB0350F1180DA0D2C1C44F97D0F081B13D33984C198ECD695C34B2E79A3E7CFBDD2D67D630C019714C3A70280E; tivi_=nqkngs45drnsh4z4y4b30g55

请帮帮我!如何创建“.ASPXAUTH”cookie?

Python请求模块使用基于cookie的身份验证为我完成这项工作。在下面的一个简单示例中,.ASPXAUTHcookie在第一次会话后被接收。get调用并用于第二次调用:

import requests
session = requests.Session()
session.get('https://host/user/login?username=###&password=###')
print session.cookies
session.get('https://host/apicall')
print session.cookies