[ESP-ENG] Titulos y enlaces en lpeproject || Titles and links in lpeproject

Preview.png

Imagen diseñada con canva || Image designed with canva

import asyncio
import aiohttp
from selectolax.parser import HTMLParser

headers={'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())

result.png

result II.png


Text translated by DeepL

H2
H3
H4
3 columns
2 columns
1 column
Join the conversation now
Ecency