diff --git a/controller/SpyderController.py b/controller/SpyderController.py index e543d73..dcdae53 100644 --- a/controller/SpyderController.py +++ b/controller/SpyderController.py @@ -51,7 +51,7 @@ class SpyderController: # headers = { # 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0' # } - f = open("file_3.csv", "a", encoding="UTF-8", newline="") + f = open("file_3.csv", "a", encoding="GB18030", newline="") csv_writer = csv.writer(f) # # rank_text = requests.get(url=url, headers=headers).text @@ -129,7 +129,7 @@ class SpyderController: return all_data_list if __name__ == '__main__': - f = open("file_3.csv", "w", encoding="UTF-8", newline="") + f = open("file_3.csv", "w", encoding="GB18030", newline="") csv_writer = csv.writer(f) csv_writer.writerow( ["bvId", "title", "url", "uploadTime", "topNo", "viewCount", "likeCount", "coinCount", diff --git a/service/CsvService.py b/service/CsvService.py index ee5ed7e..da73323 100644 --- a/service/CsvService.py +++ b/service/CsvService.py @@ -5,7 +5,7 @@ import csv class CsvService(IFileService): def save(self, filePath, videoList: list[BilibiliVideo]): - f = open(filePath+".csv", "w", encoding="UTF-8", newline="") + f = open(filePath+".csv", "w", encoding="GB18030", newline="") csv_writer = csv.writer(f) csv_writer.writerow( ["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount", diff --git a/test/SpyderController_test.py b/test/SpyderController_test.py index 31f580c..ef44f08 100644 --- a/test/SpyderController_test.py +++ b/test/SpyderController_test.py @@ -12,7 +12,7 @@ class TestSpyderController: lst = spyderController.getBilibiliVideoList(999, 1, 0.3) print(lst) # assert len(lst) == 999 - # f = open("file_3.csv", "w", encoding="UTF-8", newline="") + # f = open("file_3.csv", "w", encoding="GB18030", newline="") # csv_writer = csv.writer(f) # csv_writer.writerow( # ["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount",