<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alberto Madin Rivera</title>
    <description>The latest articles on DEV Community by Alberto Madin Rivera (@albertomadinrivera).</description>
    <link>https://dev.to/albertomadinrivera</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1471248%2Feded9cad-8a1b-40ff-be7b-72ba3d2d07e6.jpeg</url>
      <title>DEV Community: Alberto Madin Rivera</title>
      <link>https://dev.to/albertomadinrivera</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/albertomadinrivera"/>
    <language>en</language>
    <item>
      <title>Duda</title>
      <dc:creator>Alberto Madin Rivera</dc:creator>
      <pubDate>Wed, 15 May 2024 00:22:37 +0000</pubDate>
      <link>https://dev.to/albertomadinrivera/duda-4cj1</link>
      <guid>https://dev.to/albertomadinrivera/duda-4cj1</guid>
      <description>&lt;p&gt;Alguien que sepa cómo puedo ganar dinero como freelance?&lt;/p&gt;

</description>
      <category>python</category>
      <category>r</category>
      <category>rstudio</category>
      <category>chunk</category>
    </item>
    <item>
      <title>Información de Stack Overflow</title>
      <dc:creator>Alberto Madin Rivera</dc:creator>
      <pubDate>Mon, 06 May 2024 01:13:07 +0000</pubDate>
      <link>https://dev.to/albertomadinrivera/informacion-de-stack-overflow-1ag</link>
      <guid>https://dev.to/albertomadinrivera/informacion-de-stack-overflow-1ag</guid>
      <description>&lt;p&gt;Este código está destinado a extraer información de la página de preguntas Stack Overflow y almacenarla en un archivo de Texto.&lt;/p&gt;

&lt;p&gt;Importando las bibliotecas necesarias: &lt;code&gt;request&lt;/code&gt; para hacer las solicitudes HTTP, &lt;code&gt;BeautifulSoup&lt;/code&gt; de &lt;code&gt;bs4&lt;/code&gt; para analizar HTML y &lt;code&gt;pandas&lt;/code&gt; para manejar los datos en forma de Dataframe.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import requests
from bs4 import BeautifulSoup
import pandas as pd

# User agent para protegernos de baneos
headers = {
    "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/71.0.3578.80 Chrome/71.0.3578.80 Safari/537.36"
}

# URL Semilla
url = "https://stackoverflow.com/questions"

# Requerimiento al servidor
respuesta = requests.get(url, headers=headers)

# Paseo del arbol con beautifulsoup
soup = BeautifulSoup(respuesta.text)
# Encontramos elemento por ID
contenedor_de_preguntas = soup.find(id = "questions")
# Encontrar varios elemntos por tag y por clase
lista_de_preguntas = contenedor_de_preguntas.find_all("div", class_ = "s-post-summary")

# Crear una lista para almacenar los datos
datos = []

# Iteramos elemnto por elemento
for pregunta in lista_de_preguntas:

    # MÉTODO 1: Método tradicional
    # Dentro de cada elemento iterado encontrar un tag
    texto_pregunta = pregunta.find("h3").text 
    # Encontrar por clase
    descripcion_preguntas = pregunta.find(class_='s-post-summary--content-excerpt').text
    # Limpieza de texto
    descripcion_preguntas = descripcion_preguntas.replace("\n", "").replace("\r", "")
    print(texto_pregunta)
    print(descripcion_preguntas)
    print()

    # Agregar los datos a la lista
    datos.append([texto_pregunta, descripcion_preguntas])

# Agregar un DataFrame con los datos
df = pd.DataFrame(datos, columns=["Pregunta", "Descripcion"])

# Guardar el Dataframe como un archivo de texto txt
df.to_csv("preguntas_stackoverflow.txt", sep="\t",
          index=False)

# Imprimir el dataframe
print(df)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>devops</category>
      <category>webscraping</category>
    </item>
  </channel>
</rss>
