python - 为什么提取不到url编码的数据?
问题描述
这是我的代码
source_ip = line.split(’ ’)[11].strip() if re.match(’[%w]+’,source_ip):if source_ip_dict.get(source_ip,’-’)==’-’: source_ip_dict[source_ip]=1else: source_ip_dict[source_ip]=source_ip_dict[source_ip]+1
这是日志里面的数据
106.39.191.230 - - [20/Apr/2017:15:41:06 +0800] 0 'GET /article/1056 HTTP/1.1' 302 - 'https://so.m.sm.cn/s?q=%E5%B0%8F%E7%BD%90%E8%8C%B6+%E5%90%A7&uc_param_str=dnntnwvepffrgibijbprsvdsme&from=ucframe&by=submit&snum=9&uc_sm=1' 'Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; MI 5 Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 UCBrowser/11.4.5.937 Mobile Safari/537.36'183.11.69.39 - - [20/Apr/2017:16:41:10 +0800] 0 'GET /article/810 HTTP/1.1' 200 8567 'https://www.sogou.com/link?url=DSOYnZeCC_oEIb3cp8Q2nRzAwnn3W-dXaJrgRIXUqR540kn4PqPKYQ..&query=%E5%93%81%E8%8C%B6%E5%94%AF%E7%BE%8E%E6%84%8F%E5%A2%83%E5%9B%BE%E7%89%87' 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.2604.400 QQBrowser/9.6.10875.400'183.224.69.81 - - [20/Apr/2017:16:53:18 +0800] 0 'GET /article/514441 HTTP/1.1' 200 11327 'http://www.so.com/link?url=http%3A%2F%2Fwww.testurl.com%2Farticle%2F514441&q=%E5%A4%A7%E7%9B%8A%E5%AE%9D%E7%9B%92&ts=1492678364&t=40b441f225a931eddb35fbcd0bc8a3c&src=haosou' 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36'
为什么提取不到
%E5%A4%A7%E7%9B%8A%E5%AE%9D%E7%9B%92%E5%93%81%E8%8C%B6%E5%94%AF%E7%BE%8E%E6%84%8F%E5%A2%83%E5%9B%BE%E7%89%87%E5%B0%8F%E7%BD%90%E8%8C%B6+%E5%90%A7
正则写错了吗?还是哪里错了?要怎么修改
问题解答
回答1:r’[%w]+’
相关文章:
1. docker-compose 为何找不到配置文件?2. 在mac下出现了两个docker环境3. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?4. macos - mac下docker如何设置代理5. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!6. angular.js - angular内容过长展开收起效果7. PHP中的$this代表当前的类还是方法?8. objective-c - iOS开发支付宝和微信支付完成为什么跳转到了之前开发的一个app?9. dockerfile - [docker build image失败- npm install]10. java - 我用Tomcat访问SQL server数据库时,出现以下错误,该怎么解决?