12345678910111213141516171819 |
- from aiohttp import ClientSession
- from bs4 import BeautifulSoup
- async def make_request(url):
- session = ClientSession(headers={
- 'application': 'LyricsGenius',
- 'User-Agent': 'https://github.com/johnwmillr/LyricsGenius'
- })
- resp = await session.get(url)
- content = await resp.read()
- await session.close()
- return content.decode("utf-8")
- async def get_html(url):
- content = (await make_request(url)).replace('<br/>', '\n')
- return BeautifulSoup(content, "html.parser")
|