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

avatar

Preview.png

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

Hola mi querido lector. Me alegro de que estés de vuelta. He preparado para ti otro sencillo script elaborado con Python para que puedas obtener los títulos y enlaces del sitio web mashable.

Este es un portal de noticias que puedes consultar para que estés informado sobre los acontecimientos tecnológicos y científicos más recientes en nuestra civilización. En ese sentido, encontrarás información sobre smartphones, computadores de escritorio, cornetas, laptops, dispositivos IoT o gadgets. Con relación a los temas de ciencia, mayormente sostiene publicaciones sobre medio ambiente y espacio.

Así pues, si estabas buscando un sitio web muy detallado, con una interfaz ligera y agradable para la lectura, este sitio web presenta a la perfección esas características. Lo recomiendo para que realices consultas diarias.

En fin, aquí culmino esta brevísima entrega y espero que le haya gustado. Pronto volveré con más contenido para ti. Gracias por leer. Abajo encontrarás el script con su respectivo resultado.

Este script fue ejecutado con Python 3.9.13 en el sistema operativo Lubuntu 18.0.4.

Hello my dear reader. I am glad that you are back. I have prepared for you another simple script made with Python so that you can get the titles and links from the website mashable.

This is a news portal that you can consult to keep you informed about the latest technological and scientific developments in our civilization. In that sense, you will find information about smartphones, desktop computers, cornets, laptops, IoT devices or gadgets. Regarding science topics, it mostly supports publications on environment and space.

So, if you were looking for a very detailed website, with a light and pleasant interface for reading, this website perfectly presents those characteristics. I recommend it for your daily consultations.

Anyway, here I finish this very brief delivery and I hope you liked it. I will be back soon with more content for you. Thanks for reading. Below you will find the script with its respective result.

This script was run with Python 3.9.13 on the Lubuntu 18.0.4 operating system.

import httpx
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'}

def loop_urls():

urls=['https://mashable.com/tech',
    'https://mashable.com/science']

urls_list=[urls for urls in urls]
yield from urls_list

def parsing_pages():

for links in loop_urls():
    
    client=httpx.Client()
    mashable=client.get(url=links,headers=headers).text
    mashable_raw=HTMLParser(mashable)
    
    for hl in mashable_raw.css('div > a.block.w-full.text-lg.font-bold.leading-6.mt-2,section > div > div > div > div > a'):
            
            l=hl.attributes['href']
            h=hl.text(strip=True)
            print(f'links: {l} headlines: {h}')

parsing_pages()

result.png


Text translated by DeepL



1 comments
avatar

Congratulations @pynomiems! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You got more than 100 replies.
Your next target is to reach 200 replies.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out the last post from @hivebuzz:

Level up your NFTs and continue supporting the victims of war
Support the HiveBuzz project. Vote for our proposal!
0
0
0.000