Fix scraping multiple ads (#126)

Upstream has changed their content generation system. When using the same http client, the first page looks as we expect it, but subsequent pages look totally different. I can't find out why that is, but it's not an issue of this tool.

So, the "fix" is to abandon client reuse and re-initialize a new client for every http request. However, the image fetcher keeps resusing the client.

Co-authored-by: Thomas von Dein <tom@vondein.org>
Reviewed-on: https://codeberg.org/scip/kleingebaeck/pulls/126
This commit is contained in:
T. von Dein
2026-10-12 21:29:49 +02:00
parent 0d5ee0b485
commit d9f2f0a712
15 changed files with 251 additions and 69 deletions

20
ad.go
View File

@@ -29,16 +29,8 @@ type Index struct {
}
type Ad struct {
Title string `goquery:"h1"`
Slug string
ID string
Details string `goquery:".addetailslist--detail,text"`
Attributes map[string]string // processed afterwards
Condition string // post processed from details for backward compatibility
Type string // post processed from details for backward compatibility
Color string // post processed from details for backward compatibility
Material string // post processed from details for backward compatibility
Category string
Title string `goquery:"h1"`
Details string `goquery:".addetailslist--detail,text"`
CategoryTree []string `goquery:".breadcrump-link,text"`
Price string `goquery:"h2#viewad-price"`
Created string `goquery:"#viewad-extra-info,text"`
@@ -46,6 +38,14 @@ type Ad struct {
Images []string `goquery:".galleryimage-element img,[src]"`
Shipping string `goquery:".boxedarticle--details--shipping,text"` // not always filled
Expire string
Slug string
ID string
Attributes map[string]string // processed afterwards
Condition string // post processed from details for backward compatibility
Type string // post processed from details for backward compatibility
Color string // post processed from details for backward compatibility
Material string // post processed from details for backward compatibility
Category string
// runtime computed
Year, Day, Month string