From df2b05c64db1a50fddad36140e744f8f03f48207 Mon Sep 17 00:00:00 2001 From: Xarrow Date: Thu, 29 Nov 2018 22:50:53 +0800 Subject: [PATCH 1/2] Add weibo comments node , optimize code structure --- samples/tweets_persistence/tweets_persistence.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/samples/tweets_persistence/tweets_persistence.py b/samples/tweets_persistence/tweets_persistence.py index b4a533f..e44f8f5 100644 --- a/samples/tweets_persistence/tweets_persistence.py +++ b/samples/tweets_persistence/tweets_persistence.py @@ -15,13 +15,8 @@ import pickle from weibo_scraper import get_formatted_weibo_tweets_by_name -from weibo_base import rt_logger +from weibo_base import rt_logger,logger,is_debug -level = logging.DEBUG -format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' -datefmt = '%Y-%m-%d %H:%M' -logging.basicConfig(level=level, format=format, datefmt=datefmt) -logger = logging.getLogger(__name__) DEFAULT_EXPORT_FILENAME = "export_%s" % int(time.time()) DEFAULT_EXPORT_PATH = os.getcwd() @@ -114,7 +109,7 @@ def execute_with_de(self, *args, **kwargs): def persistence(self, *args, **kwargs): # TODO function to AOP - if logging.getLogger().level == logging.DEBUG: + if is_debug: self.execute_with_de(*args, **kwargs) else: self.action.execute(*args, **kwargs) @@ -258,7 +253,7 @@ def execute(self): def dispatch(name: str, pages: int = None, is_simplify: bool = True, persistence_format: str = "txt", export_file_path: str = None, export_file_name: str = None, is_debug: bool = False): if not is_debug: - logging.getLogger().setLevel(logging.ERROR) + logger.getLogger().setLevel(logging.DEBUG) if persistence_format == 'txt': pst = TxtPersistenceImpl(name=name, pages=pages, is_simplify=is_simplify, export_file_path=export_file_path, export_file_name=export_file_name) From 61795c1b4032efce15b76bba9666ffa97ded761b Mon Sep 17 00:00:00 2001 From: wb-zj268791 Date: Wed, 19 Dec 2018 12:24:56 +0800 Subject: [PATCH 2/2] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7468e79..9a82b5d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ In general , we can inspect mobile site which has it's own API by Chrome. ```shell -$ pip install weibo-scraper +$ pip install weibo-scraper==1.0.7b0 ``` @@ -45,7 +45,7 @@ $ pip install --upgrade weibo-scraper ```shell -$ pipenv install weibo-scraper +$ pipenv install weibo-scraper==1.0.7b0 ``` Or Upgrade it.