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/findimage.py

19 lines
583 B
Python
Raw Normal View History

2020-08-11 15:49:14 +00:00
import aiohttp
import re
2020-08-12 16:01:34 +00:00
from bs4 import BeautifulSoup as bs
2020-08-11 15:49:14 +00:00
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()
2020-08-12 16:01:34 +00:00
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