import peter
This commit is contained in:
45
seek/163_com/content.py
Normal file
45
seek/163_com/content.py
Normal file
@ -0,0 +1,45 @@
|
||||
import datetime
|
||||
|
||||
from DrissionPage.errors import ElementNotFoundError
|
||||
|
||||
from database.tinformationsource.model import TInformationSource
|
||||
from database.tnews.model import TNews
|
||||
from log.log_manager import logger
|
||||
from seek.content_base import ContentBase
|
||||
|
||||
|
||||
class ArticleContent(ContentBase):
|
||||
def __init__(self, news: TNews):
|
||||
super().__init__(news)
|
||||
|
||||
def get_content(self):
|
||||
try:
|
||||
content_ = self.session.s_ele('.post_body').text
|
||||
except ElementNotFoundError:
|
||||
content_ = 'not found element'
|
||||
return content_
|
||||
|
||||
|
||||
def get_content(information_source: TInformationSource) -> list:
|
||||
article_content = ArticleContent(information_source)
|
||||
result = article_content.get_content()
|
||||
article_content.finish()
|
||||
return result
|
||||
|
||||
|
||||
def content_task(news: TNews):
|
||||
logger.info(f'{news.title} news_task start execute at {datetime.datetime.now()}', )
|
||||
ofweek_com_ai = ArticleContent(news)
|
||||
ofweek_com_ai.do_seek_task()
|
||||
ofweek_com_ai.finish()
|
||||
logger.info(f'{news.title} news_task end execute at {datetime.datetime.now()}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logger.info('This module is not for direct call!')
|
||||
news_ = TNews()
|
||||
news_.is_static = True
|
||||
news_.url = 'https://www.163.com/dy/article/JKC1V4E70519DDQ2.html'
|
||||
content = get_content(news_)
|
||||
logger.info(content)
|
||||
logger.info('Done.')
|
||||
Reference in New Issue
Block a user