From c3f6f0b08df98e3d58bd4a943446f8056acf328f Mon Sep 17 00:00:00 2001 From: shmilylty Date: Mon, 26 Aug 2019 18:27:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A0=87=E9=A2=98=E8=8E=B7?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oneforall/common/request.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/oneforall/common/request.py b/oneforall/common/request.py index 59bc05b..6583a5d 100644 --- a/oneforall/common/request.py +++ b/oneforall/common/request.py @@ -101,15 +101,17 @@ def request_callback(future, index, datas): soup = BeautifulSoup(text, 'lxml') title = soup.title desc = soup.find('meta', attrs={'name': 'description'}) - head = soup.head + word = soup.find('meta', attrs={'name': 'keywords'}) if title: datas[index]['title'] = title.text.strip() elif desc: datas[index]['title'] = desc['content'].strip() - elif head: - datas[index]['title'] = head.text.strip() + elif word: + datas[index]['title'] = word['content'].strip() elif len(text) <= 200: datas[index]['title'] = text.strip() + else: + datas[index]['title'] = soup.text.strip() async def bulk_get_request(datas, port):