Created
March 21, 2017 09:00
-
-
Save dais0n/78be6c563b58329db6cf9b59e7d6785a to your computer and use it in GitHub Desktop.
detector command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/smtp" | |
"github.com/PuerkitoBio/goquery" | |
) | |
func main() { | |
auth := smtp.PlainAuth( | |
"", | |
"gmail", | |
"password", | |
"smtp.gmail.com", | |
) | |
url := "" | |
doc, err := goquery.NewDocument(url) | |
if err != nil { | |
fmt.Println(err) | |
} | |
doc.Find(".add_area").Each(func(i int, s *goquery.Selection) { | |
ptag := s.Find("p") | |
text := ptag.Text() | |
if text != "SOLD OUT" { | |
err := smtp.SendMail( | |
"smtp.gmail.com:587", | |
auth, | |
"daison@daison.com", //foo@gmail.com | |
[]string{"gmail"}, | |
[]byte("change!!!!"), | |
) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment