需求
用scapy解析每个层需要的数据
但是有一个问题是不支持http的,解决方法是安装scapy-http,具体效果请参考这里
实现完整代码:
#!/usr/bin/env python
try:
import scapy.all as scapy
except ImportError:
import scapy
try:
# This import works from the project directory
import scapy_http.http as http
except ImportError:
# If you installed this package via pip, you just need to execute this
from scapy.layers import http
import re
def processStr(data):
pattern = re.compile('^b\'(.*?)\'$', re.S)
res = re.findall(pattern, str(data))
final = re.split('\\\\r\\\\n