Skip to content

Commit

Permalink
Merge branch 'jhao104/master' of https://github.com/1again/proxy_pool
Browse files Browse the repository at this point in the history
…into 1again-jhao104/master

# Conflicts:
#	DB/DbClient.py
#	Util/GetConfig.py
  • Loading branch information
jhao104 committed Nov 12, 2018
2 parents 2591918 + 8ac170e commit 6b0b95a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ host = 127.0.0.1
port = 6379
;port = 8888
name = proxy
#password = yourpassword
;username = your_username (Only Mongodb)
;password = your_password

[ProxyGetter]
;register the proxy getter function
Expand Down
4 changes: 2 additions & 2 deletions DB/MongodbClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@


class MongodbClient(object):
def __init__(self, name, host, port):
def __init__(self, name, host, port, **kwargs):
self.name = name
self.client = MongoClient(host, port)
self.client = MongoClient(host, port, **kwargs)
self.db = self.client.proxy

def changeTable(self, name):
Expand Down
8 changes: 6 additions & 2 deletions DB/RedisClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class RedisClient(object):
Reids client
"""

def __init__(self, name, host, port):
# 为了保持DbClient的标准
# 在RedisClient里面接受username参数, 但不进行使用.
# 因为不能将username通过kwargs传进redis.Redis里面, 会报错:
# TypeError: __init__() got an unexpected keyword argument 'username'
def __init__(self, name, host, port, username, **kwargs):
"""
init
:param name:
Expand All @@ -31,7 +35,7 @@ def __init__(self, name, host, port):
:return:
"""
self.name = name
self.__conn = redis.Redis(host=host, port=port, db=0)
self.__conn = redis.Redis(host=host, port=port, db=0, **kwargs)

def get(self):
"""
Expand Down
7 changes: 5 additions & 2 deletions DB/SsdbClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ class SsdbClient(object):
验证后的代理存放在name为useful_proxy的hash中,key为代理的ip:port,value为一个计数,初始为1,每校验失败一次减1;
"""

def __init__(self, name, **kwargs):
# 为了保持DbClient的标准
# 在SsdbClient里面接受username参数, 但不进行使用.
# 因为不能将username通过kwargs传进redis.Redis里面, 会报错:
# TypeError: __init__() got an unexpected keyword argument 'username'
def __init__(self, name, username, **kwargs):
"""
init
:param name: hash name
Expand Down

0 comments on commit 6b0b95a

Please sign in to comment.