[ESP-ENG] Titulos y enlaces en nasawatch || Titles and links in nasawatch
sites·@pynomiems·
0.000 HBD[ESP-ENG] Titulos y enlaces en nasawatch || Titles and links in nasawatch
<center> https://i.ibb.co/YNTPmRv/Preview.png<center>Imagen diseñada con <a href="https://www.canva.com/">canva</a> || Image designed with <a href="https://www.canva.com/">canva</a></sub> </center> </center> <div> <div class="text-justify"> <pre> 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://nasawatch.com/page/{index}/',headers=headers) as page: nasawatch=await page.text() nasawatch_html=HTMLParser(nasawatch) for get_hl in nasawatch_html.css('div.article-category > .article-title > a'): h=get_hl.text(strip=True) l=get_hl.attributes['href'] print(f'headlines: {h} links: {l}') asyncio.run(parsing_page()) </pre> </div> <center> https://i.ibb.co/rs1q333/Result.png </center> <center> https://i.ibb.co/QccVkSs/Result-II.png </center> --- <center> ## Text translated by <a href="https://www.deepl.com/es/translator">DeepL</a> </center>