mirror of
https://github.com/Zetaphor/browser-recall.git
synced 2025-12-06 10:29:38 +00:00
All the things
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
import asyncio
|
||||
import aiohttp
|
||||
from bs4 import BeautifulSoup
|
||||
from typing import Optional
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
|
||||
class PageInfoFetcher:
|
||||
async def get_page_title(self, url: str) -> Optional[str]:
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(url, timeout=5) as response:
|
||||
if response.status == 200:
|
||||
html = await response.text()
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
return soup.title.string if soup.title else None
|
||||
except:
|
||||
return None
|
||||
@dataclass
|
||||
class PageInfo:
|
||||
url: str
|
||||
html: str
|
||||
timestamp: datetime
|
||||
Reference in New Issue
Block a user