Spaces:
Runtime error
Runtime error
File size: 735 Bytes
9f9394b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#
# SPDX-FileCopyrightText: Hadad <[email protected]>
# SPDX-License-Identifier: Apache-2.0
#
import aiohttp
from config import (
READER,
TIMEOUT,
AIOHTTP,
HEADERS,
REMINDERS
)
async def open_link(url):
try:
async with aiohttp.ClientSession(
connector=aiohttp.TCPConnector(**AIOHTTP),
timeout=aiohttp.ClientTimeout(total=TIMEOUT),
headers=HEADERS
) as session:
async with session.post(READER, data={"url": url}) as response:
response.raise_for_status()
content = await response.text()
return content + "\n\n\n" + REMINDERS
except Exception as error:
return f"Error reading URL: {str(error)}" |