convinience tool for manual testing (temporary solution)

This commit is contained in:
Egor Aristov 2025-01-17 11:10:44 +03:00
parent 0d4c9d07b1
commit 6e9b8680d9
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,57 @@
package main
import (
"github.com/egor3f/rssalchemy/internal/extractors/pwextractor"
"github.com/egor3f/rssalchemy/internal/models"
"github.com/labstack/gommon/log"
"github.com/yassinebenaid/godump"
)
func main() {
log.SetLevel(log.DEBUG)
log.SetHeader(`${level}`)
task := models.Task{
URL: "https://vombat.su",
SelectorPost: "div.post-body",
SelectorTitle: "h1 a",
SelectorLink: "h1 a",
SelectorDescription: "div.post-content-block p",
SelectorAuthor: "a:has(> span.post-author)",
SelectorCreated: "div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(2)",
SelectorContent: "div.post-content-block",
SelectorEnclosure: "article img.object-contain",
}
pwe, err := pwextractor.New()
if err != nil {
log.Panicf("create pw extractor: %v", err)
}
defer func() {
if err := pwe.Stop(); err != nil {
log.Errorf("stop pw extractor: %v", err)
}
}()
result, err := pwe.Extract(task)
if err != nil {
log.Panicf("extract: %v", err)
}
dumper := godump.Dumper{Theme: godump.Theme{
String: godump.RGB{117, 54, 217},
Quotes: godump.RGB{143, 41, 0},
Bool: godump.RGB{6, 168, 199},
Number: godump.RGB{245, 77, 13},
Types: godump.RGB{255, 105, 56},
Address: godump.RGB{50, 162, 255},
PointerTag: godump.RGB{145, 145, 145},
Nil: godump.RGB{36, 198, 229},
Func: godump.RGB{95, 165, 35},
Fields: godump.RGB{66, 79, 61},
Chan: godump.RGB{60, 101, 179},
UnsafePointer: godump.RGB{166, 62, 75},
Braces: godump.RGB{70, 169, 169},
}}
_ = dumper.Println(result)
}

1
go.mod
View File

@ -38,6 +38,7 @@ require (
github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/wasilibs/go-re2 v1.3.0 // indirect github.com/wasilibs/go-re2 v1.3.0 // indirect
github.com/yassinebenaid/godump v0.11.1 // indirect
golang.org/x/crypto v0.32.0 // indirect golang.org/x/crypto v0.32.0 // indirect
golang.org/x/exp v0.0.0-20220321173239-a90fa8a75705 // indirect golang.org/x/exp v0.0.0-20220321173239-a90fa8a75705 // indirect
golang.org/x/net v0.34.0 // indirect golang.org/x/net v0.34.0 // indirect

2
go.sum
View File

@ -86,6 +86,8 @@ github.com/wasilibs/go-re2 v1.3.0 h1:LFhBNzoStM3wMie6rN2slD1cuYH2CGiHpvNL3UtcsMw
github.com/wasilibs/go-re2 v1.3.0/go.mod h1:AafrCXVvGRJJOImMajgJ2M7rVmWyisVK7sFshbxnVrg= github.com/wasilibs/go-re2 v1.3.0/go.mod h1:AafrCXVvGRJJOImMajgJ2M7rVmWyisVK7sFshbxnVrg=
github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ=
github.com/wasilibs/nottinygc v0.4.0/go.mod h1:oDcIotskuYNMpqMF23l7Z8uzD4TC0WXHK8jetlB3HIo= github.com/wasilibs/nottinygc v0.4.0/go.mod h1:oDcIotskuYNMpqMF23l7Z8uzD4TC0WXHK8jetlB3HIo=
github.com/yassinebenaid/godump v0.11.1 h1:SPujx/XaYqGDfmNh7JI3dOyCUVrG0bG2duhO3Eh2EhI=
github.com/yassinebenaid/godump v0.11.1/go.mod h1:dc/0w8wmg6kVIvNGAzbKH1Oa54dXQx8SNKh4dPRyW44=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=