also added the type part of the detail content (original de: "Art")

This commit is contained in:
2025-02-06 12:26:02 +01:00
parent e18577b25a
commit b07694dd8a
7 changed files with 16 additions and 7 deletions

3
ad.go
View File

@@ -32,7 +32,8 @@ type Ad struct {
Slug string
ID string
Details []string `goquery:".addetailslist--detail--value,text"`
Condition string // post processed
Condition string // post processed from details
Type string // post processed from details
Category string
CategoryTree []string `goquery:".breadcrump-link,text"`
Price string `goquery:"h2#viewad-price"`

View File

@@ -40,11 +40,11 @@ const (
Defaultdir string = "."
DefaultTemplate string = "Title: {{.Title}}\nPrice: {{.Price}}\nId: {{.ID}}\n" +
"Category: {{.Category}}\nCondition: {{.Condition}}\n" +
"Category: {{.Category}}\nCondition: {{.Condition}}\nType: {{.Type}}\n" +
"Created: {{.Created}}\nExpire: {{.Expire}}\n\n{{.Text}}\n"
DefaultTemplateWin string = "Title: {{.Title}}\r\nPrice: {{.Price}}\r\nId: {{.ID}}\r\n" +
"Category: {{.Category}}\r\nCondition: {{.Condition}}\r\n" +
"Category: {{.Category}}\r\nCondition: {{.Condition}}\r\nType: {{.Type}}\r\n" +
"Created: {{.Created}}\r\nExpires: {{.Expire}}\r\n\r\n{{.Text}}\r\n"
DefaultUserAgent string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +

View File

@@ -23,6 +23,7 @@ outdir = "test"
#Id: {{.Id}}
#Category: {{.Category}}
#Condition: {{.Condition}}
#Type: {{.Type}}
#Created: {{.Created}}
#{{.Text}}

View File

@@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "KLEINGEBAECK 1"
.TH KLEINGEBAECK 1 "2024-02-10" "1" "User Commands"
.TH KLEINGEBAECK 1 "2025-02-06" "1" "User Commands"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -174,7 +174,7 @@ well. We use \s-1TOML\s0 as our configuration language. See
.PP
Format is pretty simple:
.PP
.Vb 11
.Vb 12
\& user = 1010101
\& loglevel = verbose
\& outdir = "test"
@@ -185,6 +185,7 @@ Format is pretty simple:
\& Id: {{.ID}}
\& Category: {{.Category}}
\& Condition: {{.Condition}}
\& Type: {{.Type}}
\& Created: {{.Created}}
\&
\& {{.Text}}
@@ -267,12 +268,13 @@ variables as the ad name template above.
.PP
This is the default template:
.PP
.Vb 7
.Vb 8
\& Title: {{.Title}}
\& Price: {{.Price}}
\& Id: {{.ID}}
\& Category: {{.Category}}
\& Condition: {{.Condition}}
\& Type: {{.Type}}
\& Created: {{.Created}}
\& Expire: {{.Expire}}
\&

View File

@@ -46,6 +46,7 @@ CONFIGURATION
Id: {{.ID}}
Category: {{.Category}}
Condition: {{.Condition}}
Type: {{.Type}}
Created: {{.Created}}
{{.Text}}
@@ -111,6 +112,7 @@ TEMPLATES
Id: {{.ID}}
Category: {{.Category}}
Condition: {{.Condition}}
Type: {{.Type}}
Created: {{.Created}}
Expire: {{.Expire}}

View File

@@ -46,6 +46,7 @@ Format is pretty simple:
Id: {{.ID}}
Category: {{.Category}}
Condition: {{.Condition}}
Type: {{.Type}}
Created: {{.Created}}
{{.Text}}
@@ -131,6 +132,7 @@ This is the default template:
Id: {{.ID}}
Category: {{.Category}}
Condition: {{.Condition}}
Type: {{.Type}}
Created: {{.Created}}
Expire: {{.Expire}}

View File

@@ -128,7 +128,8 @@ func ScrapeAd(fetch *Fetcher, uri string) error {
for _, detail := range advertisement.Details {
if slices.Contains(CONDITIONS, detail) {
advertisement.Condition = detail
break
} else {
advertisement.Type = detail
}
}