|
|
@@ -9,7 +9,7 @@ from mylib.base import (
|
|
|
replace_space,
|
|
|
browser_config
|
|
|
)
|
|
|
-from database.sql_model import DatabaseManager,SearchResult
|
|
|
+from database.sql_model import DatabaseManager,SearchResult,create_db_and_tables
|
|
|
from lxml import html
|
|
|
|
|
|
class SearchManager:
|
|
|
@@ -31,6 +31,7 @@ class SearchManager:
|
|
|
# 检查缓存
|
|
|
if cache:
|
|
|
existing_result = self.db_manager.get_existing_result(keyword, start)
|
|
|
+ print(f"Using existing result for {keyword} {start}")
|
|
|
if existing_result:
|
|
|
return existing_result
|
|
|
|
|
|
@@ -78,7 +79,6 @@ class SearchManager:
|
|
|
|
|
|
def save_page(self, keyword: str, start: int) -> Path:
|
|
|
"""保存当前页面"""
|
|
|
- keyword = replace_space(keyword)
|
|
|
save_dir = OUTPUT_DIR / keyword
|
|
|
ensure_output_dir(save_dir)
|
|
|
|
|
|
@@ -136,6 +136,7 @@ class SearchManager:
|
|
|
return links
|
|
|
|
|
|
async def main():
|
|
|
+ create_db_and_tables()
|
|
|
from mylib.drission_page import load_chrome_from_ini
|
|
|
|
|
|
# 初始化浏览器
|