Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/findimage.py
2020-08-18 21:12:38 +08:00

18 lines
585 B
Python

import aiohttp
import re
from bs4 import BeautifulSoup as bs
async def findimage(url):
async with aiohttp.ClientSession() as session:
async with session.get(url) as req:
if req.status != 200:
return f"请求时发生错误:{req.status}"
else:
q = await req.text()
soup = bs(q, 'html.parser')
aa = soup.find('div', id='mw-content-text')
src = aa.find_all('div', class_='fullImageLink')
z = re.match('.*<a href="(.*)"><.*', str(src), re.S)
find = re.sub(r'\?.*', '', z.group(1))
return find