diff --git a/parser_test.go b/parser_test.go index e22eaea..d6f271f 100644 --- a/parser_test.go +++ b/parser_test.go @@ -30,17 +30,29 @@ func (tt *Toutiao) GetSpiderID() int { func (tt *Toutiao) ToDoParser(adstring string) (string, error) { - adstring = strconv.QuoteToASCII(adstring) - adstring = strings.Replace(adstring, "\\", "", -1) - log.Println(adstring) + // adstring = strconv.QuoteToASCII(adstring) + // adstring = strings.Replace(adstring, "\\", "", -1) + // log.Println(adstring) - var adlist interface{} + var adlist []string if err := json.Unmarshal([]byte(adstring), &adlist); err != nil { log.Println(err) } spew.Dump(adlist) + for _, data := range adlist { + data = strconv.QuoteToASCII(data) + data = strings.Replace(data, "\\", "", -1) + log.Println(data) + + var jdata interface{} + if err := json.Unmarshal([]byte(data), &jdata); err != nil { + log.Println(err) + } + log.Println(jdata) + } + adparser := NewADParser(tt.GetSpiderID()) data, err := adparser.ToJSON() if err != nil {