-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclasses.py
More file actions
22 lines (16 loc) · 739 Bytes
/
classes.py
File metadata and controls
22 lines (16 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from bs4 import BeautifulSoup
from aiohttp import ClientSession
from responseModel import Response
class API:
url = f"https://www.dicio.com.br/"
__classSinonimos = 'adicional sinonimos'
typeParse = 'html.parser'
async def pesquisar_palavra(self, palavra: str):
async with ClientSession() as s, s.get(self.url+palavra) as r:
pageResponse = await r.text()
return BeautifulSoup(pageResponse, self.typeParse)
async def sinonimos(self, palavra):
soup = await self.pesquisar_palavra(palavra)
sinonimos = soup.find(class_=self.__classSinonimos)
resultado = [tag.text.strip() for tag in sinonimos.find_all('a')]
return await Response().Sinonimos(resultado)