batchGame/bin/soup.py
2023-06-05 13:11:47 +02:00

33 lines
654 B
Python

#!/usr/bin/env python3
import requests
import asyncio
import aiohttp
class serve:
def __init__(self, url):
self.url = url
def html(self):
try:
page = requests.get(self.url)
except:
return 'none'
content = 'none'
if page.status_code == 200:
content = page.content
return content
async def htmlAsync(self):
try:
async with aiohttp.ClientSession() as session:
async with session.get(self.url) as response:
return await response.text()
except:
return 'Error: Connection issue'