|  | @@ -50,30 +50,66 @@ class LongArticlesPipeline(object):
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  |          return response.json()['is_sensitive']
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @classmethod
 | 
	
		
			
				|  |  | +    def article_bad(cls, title, account_nickname):
 | 
	
		
			
				|  |  | +        """
 | 
	
		
			
				|  |  | +        判断该文章是否为劣质文章
 | 
	
		
			
				|  |  | +        :param title:
 | 
	
		
			
				|  |  | +        :param account_nickname:
 | 
	
		
			
				|  |  | +        :return:
 | 
	
		
			
				|  |  | +        """
 | 
	
		
			
				|  |  | +        url = "http://192.168.100.31:8176/bad/is_bad"
 | 
	
		
			
				|  |  | +        headers = {
 | 
	
		
			
				|  |  | +            "accept": "application/json",
 | 
	
		
			
				|  |  | +            "Content-Type": "application/json"
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        body = {
 | 
	
		
			
				|  |  | +            "account_nickname": account_nickname,
 | 
	
		
			
				|  |  | +            "title": title
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        response = requests.request(
 | 
	
		
			
				|  |  | +            "POST",
 | 
	
		
			
				|  |  | +            url=url,
 | 
	
		
			
				|  |  | +            headers=headers,
 | 
	
		
			
				|  |  | +            json=body
 | 
	
		
			
				|  |  | +        )
 | 
	
		
			
				|  |  | +        return response.json()['is_bad']
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @classmethod
 | 
	
		
			
				|  |  |      def deal(cls, article_obj):
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  |          :param article_obj:
 | 
	
		
			
				|  |  |          :return:
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  | -        history_exists_flag = cls.history_exists(
 | 
	
		
			
				|  |  | +        article_bad_flag = cls.article_bad(
 | 
	
		
			
				|  |  |              title=article_obj['title'],
 | 
	
		
			
				|  |  | -            account_nickname=article_obj['crawlerAccountName'],
 | 
	
		
			
				|  |  | -            plan_name=article_obj['producePlanName']
 | 
	
		
			
				|  |  | +            account_nickname=article_obj['crawlerAccountName']
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  | -        if history_exists_flag:
 | 
	
		
			
				|  |  | +        if article_bad_flag:
 | 
	
		
			
				|  |  |              response = {
 | 
	
		
			
				|  |  | -                "fileterReason": "历史已发布文章",
 | 
	
		
			
				|  |  | +                "filterReason": "历史表现差的文章",
 | 
	
		
			
				|  |  |                  "status": True
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              return response
 | 
	
		
			
				|  |  |          else:
 | 
	
		
			
				|  |  | -            safe_flag = cls.article_safe(title=article_obj['title'])
 | 
	
		
			
				|  |  | -            if safe_flag:
 | 
	
		
			
				|  |  | +            history_exists_flag = cls.history_exists(
 | 
	
		
			
				|  |  | +                title=article_obj['title'],
 | 
	
		
			
				|  |  | +                account_nickname=article_obj['crawlerAccountName'],
 | 
	
		
			
				|  |  | +                plan_name=article_obj['producePlanName']
 | 
	
		
			
				|  |  | +            )
 | 
	
		
			
				|  |  | +            if history_exists_flag:
 | 
	
		
			
				|  |  |                  response = {
 | 
	
		
			
				|  |  | -                    "fileterReason": "安全违规",
 | 
	
		
			
				|  |  | +                    "filterReason": "历史已发布文章",
 | 
	
		
			
				|  |  |                      "status": True
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |                  return response
 | 
	
		
			
				|  |  |              else:
 | 
	
		
			
				|  |  | -                return False
 | 
	
		
			
				|  |  | +                safe_flag = cls.article_safe(title=article_obj['title'])
 | 
	
		
			
				|  |  | +                if safe_flag:
 | 
	
		
			
				|  |  | +                    response = {
 | 
	
		
			
				|  |  | +                        "filterReason": "安全违规",
 | 
	
		
			
				|  |  | +                        "status": True
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    return response
 | 
	
		
			
				|  |  | +                else:
 | 
	
		
			
				|  |  | +                    return False
 |