|
@@ -0,0 +1,38 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "log"
|
|
|
+ "net/http"
|
|
|
+ "regexp"
|
|
|
+
|
|
|
+ "github.com/PuerkitoBio/goquery"
|
|
|
+)
|
|
|
+
|
|
|
+func main() {
|
|
|
+ // Wordpress
|
|
|
+ url := "https://addand.kr/shop/new-%ed%95%9c-%ea%b6%8c%ec%9c%bc%eb%a1%9c-%eb%81%9d%eb%82%98%eb%8a%94-%eb%85%b8%ec%85%98/"
|
|
|
+
|
|
|
+ response, err := http.Get(url)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ defer response.Body.Close()
|
|
|
+
|
|
|
+ doc, err := goquery.NewDocumentFromReader(response.Body)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ cEmail := "footer"
|
|
|
+
|
|
|
+ // Define findEmail as an anonymous function
|
|
|
+ findEmail := func(body string, doms string) (emails []string) {
|
|
|
+ r, _ := regexp.Compile(`[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,24}`)
|
|
|
+ emails = append(emails, r.FindStringSubmatch(body)...)
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("Email: ", findEmail(doc.Find(cEmail).First().Text(), ""))
|
|
|
+}
|