示例#1
0
def main():
    sub_index_urls = set(['http://fitnhit.com/education/','http://fitnhit.com/entertainment/','http://fitnhit.com/health/','http://fitnhit.com/news/','http://fitnhit.com/technology/'])
    site_url = 'http://fitnhit.com/'
    article_patterns = ['^http://fitnhit.com/.*/\d{5}']
    title = 'FitNHit'
    for sub_index_url in sub_index_urls:
        siterule = SiteRule.objects.get(sub_index_url=sub_index_url)
        print siterule.title
        siterule.title = title
        siterule.site_url = site_url
        siterule.article_patterns = article_patterns
        siterule.save()
    rules = Site()
    rules.title = title
    rules.url = site_url
    rules.article_patterns = article_patterns
    rules.save()
    sites = Site.objects(title='Tribune')
    if sites:
        site = sites[0]
        site.title = 'The Express Tribune'
        site.save()
    sites = Site.objects(title='Tribune India')
    if sites:
        site = sites[0]
        site.title = 'The Tribune'
        site.save()
    articles = Article.objects(title='Tribune')
    for article in articles:
        article.title = 'The Express Tribune'
        article.save()
    articles = Article.objects(title='Tribune India')
    for article in articles:
        article.title = 'The Tribune'
        article.save()
示例#2
0
文件: views.py 项目: ICCV/freyr
 def get(self, request, name, sub_name, *args, **kwargs):
    page = request.GET.get('page')
    page = int(page) if page else 0
    articles = Article.objects(source=sub_name, site_name=name).order_by('id').skip(page * COUNT).limit(COUNT) 
    return Response([ArticleProfileSerializer(article).data for article in articles])