Ai
1 Star 0 Fork 0

bit212/emailscraper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
scrape_test.go 736 Bytes
一键复制 编辑 原始数据 按行查看 历史
Law Zava 提交于 2021-03-07 19:49 +08:00 . :art:linter fixes
package emailscraper_test
import (
"testing"
"github.com/lawzava/emailscraper"
)
func TestScrape(t *testing.T) {
t.Parallel()
cfg := emailscraper.DefaultConfig()
cfg.Debug = true
s := emailscraper.New(cfg)
testCases := []struct {
name string
url string
mustContainEmail string
}{
{"cloudflare protected", "https://lawzava.com/contact/", "law@zava.dev"},
}
for _, testCase := range testCases {
emails, err := s.Scrape(testCase.url)
if err != nil {
t.Fatal(err)
}
var contains bool
for _, email := range emails {
if email == testCase.mustContainEmail {
contains = true
break
}
}
if !contains {
t.Error("email missing: ", emails)
t.Fail()
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bit212/emailscraper.git
git@gitee.com:bit212/emailscraper.git
bit212
emailscraper
emailscraper
main

搜索帮助