mirror of
https://github.com/karust/openserp.git
synced 2026-08-05 16:53:54 +08:00
35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package ecosia
|
|
|
|
import (
|
|
"github.com/PuerkitoBio/goquery"
|
|
"github.com/go-rod/rod"
|
|
"github.com/karust/openserp/core"
|
|
)
|
|
|
|
func extractEcosiaFeatures(doc *goquery.Document) []core.SerpFeature {
|
|
return core.ExtractSerpFeaturesBySelectors(doc, []core.SerpFeatureSelector{
|
|
{
|
|
Type: core.ResultTypeAnswerBox,
|
|
Title: "Answer",
|
|
Container: []string{"[data-test-id='instant-answer']", "[data-test-id='answer-box']", ".instant-answer"},
|
|
TitleSelector: []string{"h2", "[data-test-id='instant-answer-title']"},
|
|
TextSelector: []string{"[data-test-id='instant-answer-description']", "[data-test-id='answer-box-description']", ".instant-answer__description", "p"},
|
|
LinkSelector: []string{"a[href^='http']"},
|
|
Position: 1,
|
|
Confidence: 0.8,
|
|
},
|
|
{
|
|
Type: core.ResultTypeRelatedSearches,
|
|
Title: "Related searches",
|
|
Container: []string{"[data-test-id='web-related-queries']", ".related-queries__bottom", "[data-test-id='related-searches']"},
|
|
ItemSelector: []string{"a"},
|
|
LinkSelector: []string{"a[href^='http']", "a"},
|
|
Confidence: 0.8,
|
|
},
|
|
})
|
|
}
|
|
|
|
func extractEcosiaFeaturesFromPage(page *rod.Page) []core.SerpFeature {
|
|
return core.FeaturesFromPage(page, extractEcosiaFeatures)
|
|
}
|