
Research
Namastex.ai npm Packages Hit with TeamPCP-Style CanisterWorm Malware
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.
postal-code-scraper
Advanced tools
A tool for scraping country data, including regions and their postal codes
Postal Code Scraper is an automated web scraper designed to extract postal code data from countries worldwide. It efficiently fetches postal codes and organizes them into structured JSON files for easy use in applications.
This library uses Puppeteer for web scraping, Cheerio for HTML parsing, p-limit for controlling concurrency, ensuring accurate and efficient data extraction.
Install via npm:
npm install postal-code-scraper
Or with Yarn:
yarn add postal-code-scraper
import { PostalCodeScraper } from "postal-code-scraper";
const { PostalCodeScraper } = require("postal-code-scraper");
const scraper = new PostalCodeScraper();
import { PostalCodeScraper } from "postal-code-scraper";
const scraper = new PostalCodeScraper();
await scraper.scrapeCountry("Romania");
📌 Output Files (saved in ``):
romania-postal-codes.jsonromania-lookup.jsonimport { PostalCodeScraper } from "postal-code-scraper";
const scraper = new PostalCodeScraper();
await scraper.scrapeCountries();
📌 This will fetch postal codes for every available country.
| Option | Type | Default | Description |
|---|---|---|---|
directory | string | src/data | The directory to save data |
concurrency | number | 15 | Maximum concurrent requests to process |
maxRetries | number | 5 | Number of retries for failed requests |
headless | boolean | true | Run Puppeteer in headless mode |
usePrettyName | boolean | false | Use country pretty names instead of default names |
logger | object null | Logger (custom implementation) | Handles event logging, can be set to null to disable logging |
import { PostalCodeScraper } from "postal-code-scraper";
const customScraper = new PostalCodeScraper({
concurrency: 10, // Limit concurrent requests
maxRetries: 3, // Max retries per request
headless: false, // Run Puppeteer in visible mode
usePrettyName: true, // Store data using country pretty names
logger: console, // Enable console logging (set to null to disable)
directory: "src/data", // Output directory
});
await customScraper.scrapeCountry("Germany");
romania-postal-codes.json{
"cluj": {
"agarbiciu": [
"407146"
],
"aghiresu": [
"407005"
],
"cluj-napoca": [
"400001",
"400002",
"400003",
"...",
],
}
romania-lookup.json{
"postalCodeMap": {
"337563": "tamasesti_2",
"337564": "valea_4",
"400001": "cluj-napoca_1",
"400002": "cluj-napoca_1",
"400003": "cluj-napoca_1"
},
"regions": {
"cluj-napoca_1": ["cluj", "cluj-napoca"],
"tamasesti_2": ["hunedoara", "tamasesti"],
"valea_4": ["hunedoara", "valea"]
}
}
By default, they are saved in:
src/data/
Each country has two JSON files: one with raw postal codes and another with a structured lookup.
Yes, using scrapeCountries(), which scrapes all countries automatically.
Yes, by changing the directory attribute in configuration.
Yes! The package includes TypeScript types for better development experience.
You, by setting the logger attribute in configuration to null.
Contributions are welcome! Feel free to submit a pull request or open an issue.
MIT License © 2024
FAQs
A tool for scraping country data, including regions and their postal codes
We found that postal-code-scraper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Malicious Namastex.ai npm packages appear to replicate TeamPCP-style Canister Worm tradecraft, including exfiltration and self-propagation.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.