Update output.go

pull/52/head
Cyrus 5 years ago committed by GitHub
parent 519767671a
commit 21c414da70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      core/data/output.go

@ -62,6 +62,16 @@ func (c *cookies) outPutJson(browser, dir string) error {
return nil return nil
} }
func (credit *creditcards) outPutJson(browser, dir string) error {
filename := utils.FormatFileName(dir, browser, "credit", "json")
err := writeToJson(filename, credit.cards)
if err != nil {
return err
}
fmt.Printf("%s Get %d cards, filename is %s \n", utils.Prefix, len(credit.cards), filename)
return nil
}
func writeToJson(filename string, data interface{}) error { func writeToJson(filename string, data interface{}) error {
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644) f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
if err != nil { if err != nil {
@ -123,6 +133,19 @@ func (c *cookies) outPutCsv(browser, dir string) error {
return nil return nil
} }
func (credit *creditcards) outPutCsv(browser, dir string) error {
filename := utils.FormatFileName(dir, browser, "credit", "csv")
var tempSlice []card
for _, v := range credit.cards {
tempSlice = append(tempSlice, v...)
}
if err := writeToCsv(filename, tempSlice); err != nil {
return err
}
fmt.Printf("%s Get %d cards, filename is %s \n", utils.Prefix, len(credit.cards), filename)
return nil
}
func writeToCsv(filename string, data interface{}) error { func writeToCsv(filename string, data interface{}) error {
var d []byte var d []byte
f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644) f, err := os.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC|os.O_APPEND, 0644)
@ -168,3 +191,9 @@ func (p *passwords) outPutConsole() {
fmt.Printf("%+v\n", v) fmt.Printf("%+v\n", v)
} }
} }
func (credit *creditcards) outPutConsole() {
for _, v := range credit.cards {
fmt.Printf("%+v\n", v)
}
}

Loading…
Cancel
Save