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

in #siteslast year


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

import asyncio
import aiohttp
from selectolax.parser import HTMLParser

headers={'user-agent': 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_5_5 rv:3.0; sl-SI) AppleWebKit/534.49.1 (KHTML, like Gecko) Version/4.0.1 Safari/534.49.1'}

async def parsing_page():

async with aiohttp.ClientSession() as session:

    for index in range(1,6): 
        
        async with session.get(f'https://securityparrot.com/category/news/page/{index}/',headers=headers) as page:
            
            securityparrot=await page.text()
            securityparrot_html=HTMLParser(securityparrot)
             
            for get_hl in  securityparrot_html.css('div.p-content > h3 > a'):
                h=get_hl.text(strip=True)
                l=get_hl.attributes['href']

                print(f'headlines: {h} links: {l}')

asyncio.run(parsing_page())