def update_all_user_feed(): """ 更新普通订阅源 """ logger.info('开始运行定时更新 RSS 任务') now, feeds = datetime.now(), [] # 按照不同频率更新 if now.hour % 2 == 0: feeds = Site.objects.filter(status='active', creator='user').order_by('-star') elif now.hour % 2 == 1: feeds = Site.objects.filter(status='active', creator='user', star__gte=9).order_by('-star') for site in feeds: try: if not is_active_rss(site.name): if site.star < 9: continue atom_spider(site) except: logger.warning(f'爬取站点出现异常:`{site.cname}') logger.info('定时更新 RSS 任务运行结束')
def update_all_atom_cron(): """ 定时更新所有普通源 """ now, sites = datetime.now(), [] # 按照不同频率更新,区分用户自定义的和推荐的 if now.hour % 2 == 0: sites = Site.objects.filter(status='active', creator='user').order_by('-star') elif now.hour % 2 == 1: sites = Site.objects.filter(status='active', creator='user', star__gte=9).order_by('-star') for site in sites: # 无人订阅的源且不推荐的源不更新 if not is_active_rss(site.pk) and site.star < 9: continue # 是否已经更新过 if not is_updated_site(site.pk): atom_spider(site) return True
def update_all_wemp_cron(): """ 更新微信公众号,每天 1~2 次 """ sites = Site.objects.filter(status='active', creator='wemp').order_by('-star') for site in sites: # 无人订阅的源且不推荐的源不更新 if not is_active_rss(site.pk) and site.star < 9: continue if not is_updated_site(site.pk): host = get_host_name(site.rss) if 'ershicimi.com' in host: parse_wemp_ershicimi(site.rss, update=True) elif 'qnmlgb.tech' in host: atom_spider(site) else: pass return True