U: demo crawling-web-pages

This commit is contained in:
杨红岩 2024-05-06 18:31:50 +08:00
parent 00ea4abd03
commit c56061b64f
3 changed files with 18 additions and 13 deletions

View File

@ -11,13 +11,13 @@
package main
import (
"devtools/crawling"
"embed"
"fmt"
"github.com/energye/energy/v2/cef"
"github.com/energye/energy/v2/cef/ipc"
"github.com/energye/energy/v2/consts"
"github.com/energye/energy/v2/pkgs/assetserve"
"github.com/energye/erod/examples/devtools/crawling"
"github.com/energye/golcl/lcl"
)
@ -91,14 +91,19 @@ func main() {
// 抓取
ipc.On("crawling", func(windowId, testType int) {
fmt.Println("crawling windowId:", windowId)
// 在ipc里使用rod当前需要开启协程或使用异步IPC监听选项配置
if testType == testTypeDefault {
crawling.Crawling(windowId)
go crawling.Crawling(windowId)
} else if testType == testTypeUpload {
crawling.Upload(windowId)
go crawling.Upload(windowId)
} else if testType == testTypeDownload {
crawling.Download(windowId)
go crawling.Download(windowId)
}
})
// 异步IPC监听选项配置
//ipc.On("crawling", func(windowId, testType int) {
//
//}, types.OnOptions{Mode: types.MAsync})
// 测试上传
var url string

View File

@ -3,10 +3,10 @@ module devtools
go 1.19
require (
github.com/energye/energy/v2 v2.4.0
github.com/energye/erod v0.0.2
github.com/energye/energy/v2 v2.4.1
github.com/energye/erod v0.0.3
github.com/energye/golcl v1.0.10
github.com/go-rod/rod v0.115.0
github.com/go-rod/rod v0.116.0
)
require (

View File

@ -18,14 +18,14 @@ github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkU
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/energye/energy/v2 v2.4.0 h1:/RtyB57V2Jy4iTBI8mDJAgGsA/llCkxTsZJBGSC9YYw=
github.com/energye/energy/v2 v2.4.0/go.mod h1:5DqlhKr7b9p1yxA0617PwQlyoRi/gZlxzbCsnTkwAqU=
github.com/energye/erod v0.0.2 h1:Biwj9Bk8Uzh++uSWWxRebLP6FNy8UAH9wGn7PYAV4qg=
github.com/energye/erod v0.0.2/go.mod h1:M3Ow+opHCPqYFotArYliQb6dlolaIKu2RJf52o6qd3E=
github.com/energye/energy/v2 v2.4.1 h1:yNsqSZ1IZjA/u0xZiON3uA8W9hCiyNSX2NL8SZQnebQ=
github.com/energye/energy/v2 v2.4.1/go.mod h1:5DqlhKr7b9p1yxA0617PwQlyoRi/gZlxzbCsnTkwAqU=
github.com/energye/erod v0.0.3 h1:StB5tHUZXzTcy6/YdWZa3rITWc6t7peBciVWS+vAirY=
github.com/energye/erod v0.0.3/go.mod h1:Hp7+G9Y2jIMxKp3o8gfKQ1IWEi5RwgPm5mf63BGnX8Q=
github.com/energye/golcl v1.0.10 h1:ZaP12w2aqIrSjfzlTg7Lj1mJzLGYmY/mltE5CBTocts=
github.com/energye/golcl v1.0.10/go.mod h1:0wCrDx7NnHT5+gylUkKi1a9DKYewmMWZQf7xYyZuq9Y=
github.com/go-rod/rod v0.115.0 h1:xL+4BOr4sEGVphDPqpkSYWHwDOVmoCbZUmVZhEEUK+4=
github.com/go-rod/rod v0.115.0/go.mod h1:aiedSEFg5DwG/fnNbUOTPMTTWX3MRj6vIs/a684Mthw=
github.com/go-rod/rod v0.116.0 h1:ypRryjTys3EnqHskJ/TdgodFMvXV0EHvmy4bSkKZgHM=
github.com/go-rod/rod v0.116.0/go.mod h1:aiedSEFg5DwG/fnNbUOTPMTTWX3MRj6vIs/a684Mthw=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=