summaryrefslogtreecommitdiff
path: root/crawler/config.go
diff options
context:
space:
mode:
authorhorus2018-06-18 15:54:53 +0200
committerhorus2018-06-18 15:54:53 +0200
commit01e0cbe79f37b4be2fc82d31c71042b5ce4d699a (patch)
treebb179b5c5c6349a69853c3781236b6056b7e7ea6 /crawler/config.go
parent88a2628258eb5ea79736338637ab8b5b83680c92 (diff)
parent8114b7b17b723a5fe0fee24470e255faf587332e (diff)
downloadalkobote-01e0cbe79f37b4be2fc82d31c71042b5ce4d699a.tar.gz
Merge branch 'master' of /home/horus/app/fk_angebote
Diffstat (limited to 'crawler/config.go')
-rw-r--r--crawler/config.go22
1 files changed, 19 insertions, 3 deletions
diff --git a/crawler/config.go b/crawler/config.go
index f89fa45..a3939c4 100644
--- a/crawler/config.go
+++ b/crawler/config.go
@@ -17,6 +17,10 @@ type Config struct {
DBOptions string
DBPath string // for sqlite
+ UserAgent string
+ Delay int
+ IgnoreRobotsTXT bool
+
DisableURLShorter bool
Polr_URL string
Polr_API_Key string
@@ -40,6 +44,12 @@ func (c *Config) parseConfig(configFile string) {
viper.SetDefault("FixDatabase", false)
viper.SetDefault("DisableURLShorter", false)
viper.SetDefault("ShopIDs", []string{})
+ viper.SetDefault("Delay", 0)
+
+ // needs some refactoring to truly respect robots.txt
+ viper.SetDefault("IgnoreRobotsTXT", true)
+
+ viper.SetDefault("UserAgent", "colly - a friendly crawler :)")
// Name of the configuration file
viper.SetConfigName("config")
@@ -95,10 +105,16 @@ func (c *Config) setsConfig() {
c.DBDBName = viper.GetString("DB_DBName")
c.DBOptions = viper.GetString("DB_Options")
c.DBPath = viper.GetString("DB_Path")
- c.Debug = viper.GetBool("Debug")
- c.FixDatabase = viper.GetBool("FixDatabase")
+
+ c.UserAgent = viper.GetString("UserAgent")
+ c.Delay = viper.GetInt("Delay")
+ c.IgnoreRobotsTXT = viper.GetBool("IgnoreRobotsTXT")
+
c.DisableURLShorter = viper.GetBool("DisableURLShorter")
- c.ShopIDs = viper.GetStringSlice("ShopIDs")
c.Polr_URL = viper.GetString("Polr_URL")
c.Polr_API_Key = viper.GetString("Polr_API_Key")
+
+ c.Debug = viper.GetBool("Debug")
+ c.FixDatabase = viper.GetBool("FixDatabase")
+ c.ShopIDs = viper.GetStringSlice("ShopIDs")
}