diff --git a/DoubanSpider/Spider.py b/DoubanSpider/Spider.py index d5cc846..11e7869 100644 --- a/DoubanSpider/Spider.py +++ b/DoubanSpider/Spider.py @@ -2,6 +2,8 @@ from DoubanSpider import * from DoubanSpider.db import Douban, engine, Recording from sqlalchemy.orm import sessionmaker +logger = logging.getLogger("PAPA") + class DoubanBook(object): def __init__(self): @@ -108,7 +110,8 @@ class DoubanBook(object): print(f'正在保存:{name}。') self.save_csv(data) - def save_csv(self, data): + @staticmethod + def save_csv(data): with open('results.csv', 'a', encoding='utf-8') as f: writer = csv.writer(f) writer.writerow(data) diff --git a/main.py b/main.py index 28ca89e..f909a97 100644 --- a/main.py +++ b/main.py @@ -28,7 +28,6 @@ def url_pool(): if __name__ == '__main__': - logger = logging.getLogger("PAPA") sleeptime = random.randint(0, 3) with open("results.csv", "a", encoding='utf-8') as f: writer = csv.writer(f)