소스 검색

过滤删选空格换行回车字符,同时对长度大于50的字符串,截断等于50

dongzhaorui 3 년 전
부모
커밋
599c8ed450
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      find_source/crawler/analysis/DomAnalysis.py

+ 3 - 0
find_source/crawler/analysis/DomAnalysis.py

@@ -45,6 +45,9 @@ class DomAnalysis(FilterUrl):
 
         def _extract():
             name = (tag.text if len(tag.text) != 0 else None or tag.parent.text)
+            name = "".join(name.split())
+            if len(name) > 50:
+                name = "{:.50s}".format(name)
             if tag.get('href') is None:
                 return
             href = self.filter(tag.get('href'))