|
|
@@ -76,6 +76,8 @@ class SearchManager:
|
|
|
print(f"Reached last page for {keyword} at start={current_start}")
|
|
|
self.excel_db_manager.mark_keyword_done(keyword)
|
|
|
break
|
|
|
+ else:
|
|
|
+ self.go_to_next_page()
|
|
|
def save_search_result(self, keyword: str, start: int, url: str, html_path: str, is_last_page: bool = False) -> SearchResult:
|
|
|
"""保存搜索结果到数据库
|
|
|
|
|
|
@@ -182,9 +184,21 @@ def test_one():
|
|
|
key_model = key_model_list.pop(0)
|
|
|
print(key_model)
|
|
|
self.walk_search_one_keywords(key_model)
|
|
|
-
|
|
|
+def test_all():
|
|
|
+ global page
|
|
|
+ # 初始化浏览器
|
|
|
+ self = SearchManager(page)
|
|
|
+ key_model_list = self.excel_db_manager.get_keywords_by_status()
|
|
|
+ print("遍历所有搜索词, len = ", len(key_model_list))
|
|
|
+ # 遍历所有搜索词
|
|
|
+ for key_model in key_model_list:
|
|
|
+ print('---------------------------')
|
|
|
+ print(f"Processing keyword: {key_model.key_word}")
|
|
|
+ self.walk_search_one_keywords(key_model)
|
|
|
+
|
|
|
async def main():
|
|
|
create_db_and_tables()
|
|
|
+ test_all()
|
|
|
# test_one()
|
|
|
# global page
|
|
|
# self = SearchManager(page)
|