This commit is contained in:
eson 2018-12-20 02:03:30 +08:00
parent efb9fe36a1
commit 887a0fd664

View File

@ -30,17 +30,29 @@ func (tt *Toutiao) GetSpiderID() int {
func (tt *Toutiao) ToDoParser(adstring string) (string, error) { func (tt *Toutiao) ToDoParser(adstring string) (string, error) {
adstring = strconv.QuoteToASCII(adstring) // adstring = strconv.QuoteToASCII(adstring)
adstring = strings.Replace(adstring, "\\", "", -1) // adstring = strings.Replace(adstring, "\\", "", -1)
log.Println(adstring) // log.Println(adstring)
var adlist interface{} var adlist []string
if err := json.Unmarshal([]byte(adstring), &adlist); err != nil { if err := json.Unmarshal([]byte(adstring), &adlist); err != nil {
log.Println(err) log.Println(err)
} }
spew.Dump(adlist) 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()) adparser := NewADParser(tt.GetSpiderID())
data, err := adparser.ToJSON() data, err := adparser.ToJSON()
if err != nil { if err != nil {