From 82973c295c91775ca82510900b5e8e3f00545a32 Mon Sep 17 00:00:00 2001 From: shmilylty Date: Mon, 19 Aug 2019 02:24:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=87=E9=A2=98=E4=BF=A1=E6=81=AF=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oneforall/common/request.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/oneforall/common/request.py b/oneforall/common/request.py index f7e33bb..c6e3d4c 100644 --- a/oneforall/common/request.py +++ b/oneforall/common/request.py @@ -100,13 +100,16 @@ def request_callback(future, index, datas): datas[index]['banner'] = banner soup = BeautifulSoup(text, 'lxml') title = soup.title + desc = soup.find('meta', attrs={'name': 'description'}) head = soup.head if title: - datas[index]['title'] = title.text + datas[index]['title'] = title.text.strip() + elif desc: + datas[index]['title'] = desc['content'].strip() elif head: - datas[index]['title'] = head.text + datas[index]['title'] = head.text.strip() elif len(text) <= 200: - datas[index]['title'] = text + datas[index]['title'] = text.strip() async def bulk_get_request(datas, port):