新浪微博cookies格式 与python里面http.cookies的bug?,pythonhttp.cookies,登录新浪微博时获取到co
新浪微博cookies格式 与python里面http.cookies的bug?,pythonhttp.cookies,登录新浪微博时获取到co
登录新浪微博时获取到cookies的expires是Saturday, 06-Mar-2027 02:32:46 GMT;这样的格式,但是http.cookies库解析时expires的需要的格式是Sat, 06-Mar-2027 02:32:46 GMT;,使用的正则表达式如下:
_CookiePattern = re.compile(r""" \s* # Optional whitespace at start of cookie (?P<key> # Start of group 'key' [""" + _LegalKeyChars + r"""]+? # Any word of at least one letter ) # End of group 'key' ( # Optional group: there may not be a value. \s*=\s* # Equal Sign (?P<val> # Start of group 'val' "(?:[^\\"]|\\.)*" # Any doublequoted string | # or \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr | # or [""" + _LegalValueChars + r"""]* # Any word or empty string ) # End of group 'val' )? # End of optional value group \s* # Any number of spaces. (\s+|;|$) # Ending either at space, semicolon, or EOS. """, re.ASCII | re.VERBOSE) # re.ASCII may be removed if safe.
这个正则表达式解析微博cookies时会在expries处出错,需要把\w{3}改成\w{3,9}才能正确解析微博的cookies。
我想问的是http有对expries规定格式吗?这个bug是属于新浪不按格式还是http.cookies解析不兼容?而使用requests库解析时没有有题。
应该是新浪写的就是 Sat 而浏览器显示会补全
编橙之家文章,
相关内容
- Python re正则可以匹配中文词组吗,pythonre中文词组,情景
- 请高手看下sql查询转换成sqlalchemy语句可行性大不大,
- Python微信回复消息unicode问题求助,pythonunicode,服务器搭
- 把Python3.3.5转成.exe文件如何实现,,RT,网上查了方法,
- python 解析网页不出来,python解析不出来,import urlli
- Django前后端分离操作,如何配置使用模版引擎方法,
- Python列表ZIP相邻元素代码的含义是什么,pythonzip,请问各
- Python分片赋值求详细讲解,,最近在看 http://
- 企业面试时遇到python括号匹配笔面问题求解,面试时
- 请教ACK扫描TCP端口RST报文TTL返回值的问题,ackrst,书上说
评论关闭