框架确立

Excel
Timmoc 10 months ago
parent 00da72cf7a
commit 840df4d727

@ -0,0 +1,9 @@
class SpyderController:
def getBilibiliVideoList(self,videoCount,threadCount,waitTime):
"""
整个爬虫的调用程序
:param videoCount: 爬取的视频数量若不限制可设置为999
:param threadCount: 爬取的线程并发数量
:param waitTime:float: 每个线程的等待时间单位秒避免爬取过快
:return: list[BilibiliVideo] 返回处理完成后的videoList
"""

@ -0,0 +1,6 @@
class UIController:
def main(self):
"""
UI的主进程启动UI界面并保持当return时表示UI界面已经被关闭
:return: void
"""

@ -0,0 +1,35 @@
import time
class BilibiliVideo:
def __init__(self, bvId, title, url, uploadTime, topNo, viewCount, likeCount, coinCount,
favoriteCount, commentCount, bulletCount, creatorId, creatorName, creatorFanCount):
self.bvId = bvId # 视频标题
self.title = title # 视频bv号
self.url = url # 指向视频的url
self.uploadTime = uploadTime # 视频上传时间 时间统一至时间戳(秒)
timeArray = time.localtime(uploadTime)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
self.uploadTimeText = otherStyleTime # 视频上传时间(文本型) 由时间戳转换而来
self.topNo = topNo # 视频热门榜排名
self.viewCount = viewCount # 视频播放量
self.likeCount = likeCount # 视频点赞
self.coinCount = coinCount # 视频投币
self.favoriteCount = favoriteCount # 视频收藏
self.commentCount = commentCount # 视频评论数
self.bulletCount = bulletCount # 视频弹幕数
self.creatorId = creatorId # up主账号
self.creatorName = creatorName # up主昵称
self.creatorFanCount = creatorFanCount # up主粉丝量

@ -0,0 +1,13 @@
from controller.SpyderController import SpyderController
from controller.UIController import UIController
spyderController = SpyderController()
uiController = UIController()
if __name__ == '__main__':
print("this is main.py!")
# for debug:
lst = spyderController.getBilibiliVideoList(999,1,0.3)
print(lst)
# for running:
uiController.main()

@ -0,0 +1,7 @@
from IFileService import IFileService
from entity.BilibiliVideo import BilibiliVideo
class CsvService(IFileService):
def save(self, filePath, videoList: list[BilibiliVideo]):
raise NotImplementedError

@ -0,0 +1,13 @@
from IFileService import IFileService
from entity.BilibiliVideo import BilibiliVideo
class ExcelService(IFileService):
def __init__(self):
"""
此处增加对excel的高级参数若有
"""
pass
def save(self, filePath, videoList: list[BilibiliVideo]):
raise NotImplementedError

@ -0,0 +1,15 @@
from abc import abstractmethod, ABCMeta
from entity.BilibiliVideo import BilibiliVideo
class IFileService(metaclass=ABCMeta):
@abstractmethod
def save(self,filePath,videoList:list[BilibiliVideo]):
"""
保存到文件高级参数在init里面写
:param filePath: 文件保存路径
:param videoList: 欲保存成目标的实体类list
:return: void
"""
pass
Loading…
Cancel
Save