mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 12:57:50 +08:00
优化标题获取
This commit is contained in:
@@ -101,15 +101,17 @@ def request_callback(future, index, datas):
|
|||||||
soup = BeautifulSoup(text, 'lxml')
|
soup = BeautifulSoup(text, 'lxml')
|
||||||
title = soup.title
|
title = soup.title
|
||||||
desc = soup.find('meta', attrs={'name': 'description'})
|
desc = soup.find('meta', attrs={'name': 'description'})
|
||||||
head = soup.head
|
word = soup.find('meta', attrs={'name': 'keywords'})
|
||||||
if title:
|
if title:
|
||||||
datas[index]['title'] = title.text.strip()
|
datas[index]['title'] = title.text.strip()
|
||||||
elif desc:
|
elif desc:
|
||||||
datas[index]['title'] = desc['content'].strip()
|
datas[index]['title'] = desc['content'].strip()
|
||||||
elif head:
|
elif word:
|
||||||
datas[index]['title'] = head.text.strip()
|
datas[index]['title'] = word['content'].strip()
|
||||||
elif len(text) <= 200:
|
elif len(text) <= 200:
|
||||||
datas[index]['title'] = text.strip()
|
datas[index]['title'] = text.strip()
|
||||||
|
else:
|
||||||
|
datas[index]['title'] = soup.text.strip()
|
||||||
|
|
||||||
|
|
||||||
async def bulk_get_request(datas, port):
|
async def bulk_get_request(datas, port):
|
||||||
|
|||||||
Reference in New Issue
Block a user