1
babyname 2015-06-25 12:44:48 +08:00
awk
|
2
mongodb 2015-06-25 12:45:48 +08:00
只能告诉你使用awk..具体怎么弄可以查询awk使用方法。
|
5
neo2015 2015-06-25 13:07:18 +08:00
|
6
ihciah 2015-06-25 14:04:12 +08:00
import urlparse
url="127.0.0.1 533 [06/Jun/2015:10:26:31 +0800]- - 200 25994 127.0.0.1 8080 GET /xgz/download?_dc=18088889999&source=gdtjf8934h9hee&title=&author=&processName=&page=1&start=0&limit=50" url=url[url.find('?'):] d=dict(urlparse.parse_qsl(url)) print d['_dc'] 记得转义 |
7
ihciah 2015-06-25 14:15:07 +08:00
@ihciah
纠正:url=url[url.find('?'):] -> url=url[url.find('?')+1:] 附插入数据库代码: import pymysql conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='', db='mylog',charset='utf8') cur = conn.cursor() p=lambda x:pymysql.escape_string(x) cur.execute("INSERT INTO xx(a,b,c) VALUES('%s','%s','%s')" %(p(d['_dc']),p(d['source']),p(d['title']))) conn.commit() cur.close() conn.close() |