[ESP-ENG] Enlaces y títulos de moneycontrol con Python || Moneycontrol links and titles with Python

in GEMS4 years ago (edited)

preview.png

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

Saludos hivers. les presto un script para obtener noticias del sitio web https://www.moneycontrol.com/ un sitio financiero creado en 1999 que ofrece información sobre economía y finanzas, tiene una sección para realizar inversiones, análisis de datos, herramientas financieras y monitorear las finanzas corporativas y personales.

Para extraer más titulares y enlaces de este sitio web debe de agregar al final de la URL /page-2/ la URL quedará estructurada de la siguiente manera: https://www.moneycontrol.com/news/business/economy/page-2/ en /page-/ debe de reemplazarlo por el número de la página de la que usted quiera obtener los enlaces.

Les dejo el script, espero que esta herramienta sea provechosa para ustedes. Hasta la próxima.

Greetings hivers. I lend you a script to get news from the web site https://www.moneycontrol.com/ a financial site created in 1999 that offers information on economics and finance. financial site created in 1999 that offers information about economy and finance, it has a section to make investments, data analysis, financial tools and monitor corporate and personal finance.

To extract more headlines and links from this website you must add at the end of the URL /page-2/ the URL will be structured as follows: https://www.moneycontrol.com/news/business/economy/page-2/ in /page-/ you must replace it with the number of the page you want to get the links.

I leave you to the script I hope this tool will be useful for you. See you next time.

import httpx
from selectolax.parser import HTMLParser
page= 'https://www.moneycontrol.com/news/business/economy/'
client=httpx.Client()
reponse=client.get(page)
parse=reponse.text
for data in HTMLParser(parse).css('h2 > a'):
    title=data.attrs['title']
    links=data.attrs['href']
    print({title},{links})

Result.png


Text translated by DeepL

Sort:  

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

You distributed more than 600 upvotes.
Your next target is to reach 700 upvotes.

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

To support your work, I also upvoted your post!

Check out the last post from @hivebuzz:

Hive Power Up Month - Feedback from April day 6
NFT for Peace - Feedback and new city
Support the HiveBuzz project. Vote for our proposal!