【Python】txt数据处理

实战场景

使用safe3wvs扫描,扫描完成后会在当前目录下生成一个日志文件spider.log,截图如下。

现要求将存在sql注入的url地址整理到spider_new.log文件中,下面分享一个自己用python编写的脚本:

#coding:utf-8

with open('spider.log','r') as fr:
    for line in fr.readlines():
        if 'sql' in line:
            with open('spider_new.log','a') as fw:
                fw.write(line.split(' ')[0]+'\n')

执行结果:

 

posted @ 2018-04-02 15:54  Carrypan  阅读(1576)  评论(0编辑  收藏  举报