From e4830dd1629c054e9c1c2a61620d737691439792 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 14 Mar 2015 15:54:26 +0800 Subject: [PATCH] add 'user_agent' config for the regex source --- README.rst | 3 +++ nvchecker/source/regex.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/README.rst b/README.rst index 341c6d2..9ccbfd2 100644 --- a/README.rst +++ b/README.rst @@ -91,6 +91,9 @@ regex proxy The HTTP proxy to use. The format is ``host:port``, e.g. ``localhost:8087``. This requires `pycurl `_. +user_agent + The ``User-Agent`` header value to use. Use something more like a tool (e.g. ``curl/7.40.0``) in Europe or the real web page won't get through because cookie policies (SourceForge has this issue). + Find with a Command ------------------- Use a shell command line to get the version. The output is striped first, so trailing newlines do not bother. diff --git a/nvchecker/source/regex.py b/nvchecker/source/regex.py index 839c5b1..9279784 100644 --- a/nvchecker/source/regex.py +++ b/nvchecker/source/regex.py @@ -30,6 +30,8 @@ def get_version(name, conf, callback): kwargs['proxy_port'] = int(port) else: logger.warn('%s: proxy set but not used because pycurl is unavailable.', name) + if conf.get('user_agent'): + kwargs['user_agent'] = conf['user_agent'] httpclient.fetch(conf['url'], partial( _got_version, name, r, encoding, callback