Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4006975a21 |
22
scrape.go
22
scrape.go
@@ -84,6 +84,27 @@ func (c *chaseScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *citiScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
func (c *citiScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
||||||
|
date := fmt.Sprint(m.Header["Date"])
|
||||||
|
b, err := ioutil.ReadAll(m.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
re := regexp.MustCompile(`Citi Alert: A \$[0-9][0-9]*\.[0-9][0-9] transaction was made at .* on card ending in`)
|
||||||
|
match := re.Find(b)
|
||||||
|
if len(match) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
rePrice := regexp.MustCompile(`[0-9][0-9]*\.[0-9][0-9]`)
|
||||||
|
price := rePrice.Find(match)
|
||||||
|
|
||||||
|
vendor := bytes.Split(bytes.Split(match, []byte(" on card ending in"))[0], []byte("transaction was made at "))[1]
|
||||||
|
|
||||||
|
transaction := NewTransaction(string(price), string(vendor), date, Citi)
|
||||||
|
|
||||||
|
return []*Transaction{transaction}, nil
|
||||||
|
//Citi Alert: A $598.14 transaction was made at REMIX MUSIC SPRINGDA on card ending in 3837
|
||||||
|
/*
|
||||||
b, err := ioutil.ReadAll(m.Body)
|
b, err := ioutil.ReadAll(m.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -121,4 +142,5 @@ func (c *citiScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return transactions, nil
|
return transactions, nil
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
0
transaction_test.go
Normal file → Executable file
0
transaction_test.go
Normal file → Executable file
Reference in New Issue
Block a user