mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2026-11-23 06:59:00 +01:00
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:
4
store.go
4
store.go
@@ -127,7 +127,6 @@ func WriteImage(filename string, reader *bytes.Reader) error {
|
||||
}()
|
||||
|
||||
_, err = reader.WriteTo(file)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write to image file: %w", err)
|
||||
}
|
||||
@@ -157,7 +156,6 @@ func ReadImage(filename string) (*bytes.Buffer, error) {
|
||||
|
||||
func fileExists(filename string) bool {
|
||||
info, err := os.Stat(filename)
|
||||
|
||||
if err != nil {
|
||||
// return false on any error
|
||||
return false
|
||||
@@ -172,11 +170,13 @@ func CheckAdVisited(conf *Config, adname string) bool {
|
||||
if Exists(DirsVisited, adname) {
|
||||
if conf.ForceDownload {
|
||||
slog.Warn("an ad with the same name has already been downloaded, overwriting", "addir", adname)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// don't overwrite
|
||||
slog.Warn("an ad with the same name has already been downloaded, skipping (use -f to overwrite)", "addir", adname)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user