TODO: extractor openrec

This commit is contained in:
eson
2020-07-10 12:05:33 +08:00
parent 2e9a803645
commit 4af5430572
17 changed files with 4117 additions and 34 deletions

View File

@@ -0,0 +1,5 @@
package main
func main() {
}

View File

@@ -0,0 +1,37 @@
package main
import (
"intimate"
"os"
"testing"
"github.com/tidwall/gjson"
)
func TestExtractor(t *testing.T) {
store := intimate.NewSourceStore("source_openrec")
source, err := store.Pop("openrec_user", 100)
if source != nil {
defer store.Restore(source)
}
if err != nil {
t.Error(err)
}
sdata := source.GetExt().([]byte)
if gjson.ValidBytes(sdata) {
result := gjson.ParseBytes(sdata)
m := result.Map()
for key := range m {
t.Error(key)
f, err := os.OpenFile("./openrec_"+key+".html", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm)
if err != nil {
panic(err)
}
f.WriteString(m[key].String())
}
} else {
t.Error("data is not json:\n", string(sdata))
}
}