Skip to content

Instantly share code, notes, and snippets.

@dais0n
Created March 21, 2017 09:00
Show Gist options
  • Save dais0n/78be6c563b58329db6cf9b59e7d6785a to your computer and use it in GitHub Desktop.
Save dais0n/78be6c563b58329db6cf9b59e7d6785a to your computer and use it in GitHub Desktop.
detector command
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