Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Correos de Chile Postal Code Scraper 🇨🇱

This is a Python scraper that extracts Chilean postal codes from correos.cl using Playwright. It simulates filling out the public form with autocomplete validation and returns the result in clean JSON format.


✅ Features

  • Fully automated browser-based scraping (headless by default)
  • Robust autocomplete handling for commune and street
  • Input verification for all fields
  • Input normalization: supports uppercase/lowercase, tildes, and special characters
  • JSON output:
    • On success: { "postalCode": "8260323" }
    • On error: { "error": "..." }
  • Ready to convert into an API with Django

🚀 Quickstart

1. Install dependencies

pip install -r requirements.txt
playwright install

2. Run the scraper

python index.py "LA FLORIDA" "LAS ACACIAS" "7700"

Example Output (Success)

{ "postalCode": "8260323" }

Example Output (Error)

{
  "error": "Scraper failed: Failed to select street correctly after 2 attempts."
}

📁 Files

  • index.py: main script
  • error.png: generated screenshot on error (if applicable)
  • requirements.txt: dependency list

🔧 Notes

  • This scraper uses Playwright under the hood.
  • Form fields require autocomplete selection; manual filling is not enough.
  • Input values are normalized to match Correos' expected format (e.g. PeñalolénPENALOLEN)
  • Timeout is set to 20s by default per operation.

📦 Ready for API?

Yes. You can now easily wrap this logic inside a Django or Flask API endpoint.


👤 Author

Alejandro Exequiel Hernández Lara Founder & CEO at KaiNext

About

Python scraper that automates postal-code lookups on the official Correos de Chile site — simulates the search form with autocomplete logic and returns clean, structured JSON, ready for any API-driven backend.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages