import peter

This commit is contained in:
konjacpotato
2025-11-12 20:42:16 +08:00
commit 8c1a740f0b
147 changed files with 2763 additions and 0 deletions

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

62
seek/ofweek_com/ai.py Normal file
View File

@ -0,0 +1,62 @@
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.seek_base import SeekBase
from utils.time_utils import process_time
class OfweekComAi(SeekBase):
def __init__(self, information_source: TInformationSource):
super().__init__(information_source)
def get_news(self):
news_result = []
_news_list = self.session.s_ele('.main-cont-left w640').s_eles('.^top-title')
for _news in _news_list:
try:
__news = TNews()
__news.title = _news.s_ele('tag:a').text
__news.url = _news.s_ele('tag:a').link
_time = _news.parent().s_eles('tag:span')[4].text
__news.occurrence_date = process_time(_time)
__news.source = self.information_source.title
news_result.append(__news)
except ElementNotFoundError as e:
logger.error(f"ElementNotFoundError: {e} - Failed to find element in news item.")
except Exception as e:
logger.error(f'Unexpected error occurred: {e}')
return news_result
def get_news(information_source: TInformationSource) -> list:
ofweek_com_ai = OfweekComAi(information_source)
news_list = ofweek_com_ai.get_news()
ofweek_com_ai.finish()
return news_list
def news_task(information_source: TInformationSource):
logger.info(f'{information_source.title} news_task start execute at {datetime.datetime.now()}', )
ofweek_com_ai = OfweekComAi(information_source)
ofweek_com_ai.do_seek_task()
ofweek_com_ai.finish()
logger.info(f'{information_source.title} news_task end execute at {datetime.datetime.now()}')
if __name__ == '__main__':
logger.info('This module is not for direct call!')
information_source_ = TInformationSource()
information_source_.is_static = True
information_source_.url = 'https://www.ofweek.com/ai/'
information_source_.title = '人工智能_维科网'
news_task(information_source_)
# news_list_ = get_news(information_source_)
# for news in news_list_:
# print(news)
logger.info('Done.')

View File

@ -0,0 +1,46 @@
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):
content_ = ''
try:
content_ = self.session.s_ele('.artical-content').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.ofweek.com/ai/2024-12/ART-201721-8120-30654143.html'
content = get_content(news_)
logger.info(content)
logger.info('Done.')