Skip to main content
This page documents the main functions and modules used in the Historia Para Gandules project.

scraping5.py

The Instagram scraping script that collects reel data from the historiaparagandules profile.

Main Components

L
instaloader.Instaloader
The main Instaloader instance used to authenticate and access Instagram data.
profile_name
string
default:"historiaparagandules"
The Instagram profile username to scrape data from.

Data Collection

The script iterates through all posts from the profile and filters video content (reels). For each video post, it extracts:
fecha
datetime
Post date in YYYY-MM-DD HH:MM:SS format
texto
string
Caption text of the reel (or “Sin texto” if none)
likes
integer
Number of likes on the post
comentarios
integer
Number of comments on the post
url_video
string
Direct URL to the video file
visualizaciones
integer
View count for the video
duracion_video
float
Video duration in seconds
url_post
string
Instagram post URL in format https://www.instagram.com/p/{shortcode}/

Output

The script saves all collected data to informacion_reels_simple.csv with UTF-8 encoding.

mapita5.py

Generates an interactive map visualization of Instagram reel locations using Folium.

Functions

obtener_coordenadas()

def obtener_coordenadas(localizacion)
Parses coordinate strings and returns latitude/longitude values.
localizacion
string
required
Coordinate string in format "latitude,longitude"
Returns: Tuple of (lat, lon) as floats, or (None, None) if parsing fails. Example:
lat, lon = obtener_coordenadas("28.1234,-15.5678")
# Returns: (28.1234, -15.5678)

descargar_imagen()

def descargar_imagen(url, index)
Downloads an image from a URL and saves it locally.
url
string
required
Direct URL to the image file
index
integer
required
Unique identifier for the image filename
Returns: String path to saved image (imagenes/imagen_{index}.jpg) or None if download fails. Behavior:
  • Creates imagenes/ directory if it doesn’t exist
  • Downloads images in chunks of 1024 bytes
  • Handles HTTP errors gracefully

Map Configuration

location
array
default:"[28.0, -15.0]"
Initial map center coordinates [latitude, longitude] - centered on Canary Islands
zoom_start
integer
default:"6"
Initial zoom level for the map

Marker Popups

Each marker displays:
  • First word of the reel caption as title
  • Thumbnail image (200px width, auto height)
  • Link to Instagram post

Output

Saves interactive HTML map to mapa_ubicaciones_reels_with_thumbnails.html

Data Analysis (EDA.ipynb)

The exploratory data analysis notebook provides statistical insights.

Key Metrics

  • Average Likes: ~1,316 per post
  • Average Comments: ~39 per post
  • Average Views: ~15,392 per post
  • Average Duration: ~50 seconds

Categories

Content is categorized into:
  • Toponimia de Lugares (Place Names)
  • Curiosidades Históricas (Historical Curiosities)
  • Biografías de Personajes Históricos (Historical Biographies)
  • Arquitectura (Architecture)
  • Acontecimientos Históricos (Historical Events)

Build docs developers (and LLMs) love