import asyncio
import aiohttp
from selectolax.parser import HTMLParserheaders={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75'}
async def parsing_page():
async with aiohttp.ClientSession() as session: for idx in range(1,6): async with session.get(f'https://lpeproject.org/blog/page/{idx}/',headers=headers) as page: lpeproject=await page.text() lpeproject_html=HTMLParser(lpeproject) for hl in lpeproject_html.css('h2 > a'): headlines=hl.text(strip=True) links=hl.attributes['href'] print(f'headlines: {headlines} links: {links}')
asyncio.run(parsing_page())