编码格式改为GB18030

UIController
lfk 9 months ago
parent f8ca53cde2
commit 3de235526a

@ -51,7 +51,7 @@ class SpyderController:
# headers = { # headers = {
# 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0' # '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) csv_writer = csv.writer(f)
# #
# rank_text = requests.get(url=url, headers=headers).text # rank_text = requests.get(url=url, headers=headers).text
@ -129,7 +129,7 @@ class SpyderController:
return all_data_list return all_data_list
if __name__ == '__main__': 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 = csv.writer(f)
csv_writer.writerow( csv_writer.writerow(
["bvId", "title", "url", "uploadTime", "topNo", "viewCount", "likeCount", "coinCount", ["bvId", "title", "url", "uploadTime", "topNo", "viewCount", "likeCount", "coinCount",

@ -5,7 +5,7 @@ import csv
class CsvService(IFileService): class CsvService(IFileService):
def save(self, filePath, videoList: list[BilibiliVideo]): 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 = csv.writer(f)
csv_writer.writerow( csv_writer.writerow(
["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount", ["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount",

@ -12,7 +12,7 @@ class TestSpyderController:
lst = spyderController.getBilibiliVideoList(999, 1, 0.3) lst = spyderController.getBilibiliVideoList(999, 1, 0.3)
print(lst) print(lst)
# assert len(lst) == 999 # 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 = csv.writer(f)
# csv_writer.writerow( # csv_writer.writerow(
# ["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount", # ["topNo", "bvId", "title", "url", "uploadTime", "viewCount", "likeCount", "coinCount", "favoriteCount",

Loading…
Cancel
Save