Imagen diseñada con canva || Image designed with canva
Saludos comunidad de Hive. Hoy les presento un nuevo script elaborado con Python para obtener los enlaces y títulos en la página principal del sitio web codeforgeek.
Si gustas de la programación o quieres aprender este es un sitio que en la mayoría de sus publicaciones se centra en ofrecernos guías, tutoriales, revisiones y recomendaciones de desarrollo acerca de Python, JavaScript y Linux. Por supuesto, aborda otras temáticas sobre noticias relevantes del sector tecnológico orientado a la programación.
Si ingresan a este sitio web, notará de inmediato que fue elaborado con el objetivo de proporcionar una interfaz gráfica simple y que facilite la búsqueda de publicaciones. Tiene más de 7 años en funcionamiento y actualmente recibe millones de visitas y que cuenta con una comunidad de desarrolladores de diferentes áreas que han sido exitoso en su campo.
Bueno, sin más nada que agregar les dejo el acceso al sitio web, el script elaborado en Python con sus resultados.
Agradezco que hayan visitado mi blog hasta el próximo encuentro mis Hivers.
Este script fue ejecutado con Python 3.9.13 en el sistema operativo Lubuntu 18.0.4.
Greetings Hive community. Today I present a new script made with Python to get the links and titles on the home page of the codeforgeek website.
If you like programming or want to learn this is a site that in most of its publications focuses on offering us guides, tutorials, reviews and development recommendations about Python, JavaScript and Linux. Of course, it addresses other topics about relevant news from the technology sector oriented to programming.
If you enter this website, you will immediately notice that it was developed with the aim of providing a simple graphical interface and to facilitate the search for publications. It has more than 7 years in operation and currently receives millions of visits and has a community of developers from different areas that have been successful in their field.
Well, with nothing more to add I leave you the access to the web site, the script elaborated in Python with its results.
Thank you for visiting my blog until the next meeting my Hivers.
This script was run with Python 3.9.13 on the Lubuntu 18.0.4 operating system.
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: url='https://codeforgeek.com/' async with session.get(url,headers=headers) as page: codeforgeek = await page.text() codeforgeek_page = HTMLParser(codeforgeek) for search in codeforgeek_page.css('h2 > a'): headlines=search.text() links=search.attributes['href'] print(f'headlines: {headlines} links: {links}')
asyncio.run(parsing_page())