@immo24/decoder
v0.1.1
Published
Decode encoded address data from ImmoScout24 listings
Maintainers
Readme
@immo24/decoder
Decodes encoded address data from ImmoScout24 listing pages.
ImmoScout24 embeds address information in the page as a Base64-encoded JSON string inside the obj_telekomInternetUrlAddition property. This package extracts and decodes that data into a structured Address object.
Installation
npm install @immo24/decoderUsage
import { decodeAddress } from '@immo24/decoder';
// Encoded string extracted from the ImmoScout24 page source
const encoded = '...';
const address = decodeAddress(encoded);
if (address) {
console.log(address.street); // e.g. "Musterstraße"
console.log(address.houseNumber); // e.g. "42"
console.log(address.postalCode); // e.g. "10115"
console.log(address.city); // e.g. "Berlin"
console.log(address.district); // e.g. "Mitte"
}Finding the encoded string
The encoded address is embedded in the page HTML as a JSON property:
"obj_telekomInternetUrlAddition": "<encoded-value>"You can extract it from the page source via a regex:
const match = html.match(/"obj_telekomInternetUrlAddition"\s*:\s*"([^"]+)"/);
const encoded = match?.[1] ?? null;
const address = decodeAddress(encoded);API
decodeAddress(encoded: string | null): Address | null
Decodes an encoded address string. Returns null if the input is null, empty, or cannot be decoded.
Address
interface Address {
street: string;
houseNumber: string;
postalCode: string;
city: string;
district: string;
}Advanced usage
For custom decoding strategies, the underlying building blocks are also exported:
import {
DecodingStrategyChain,
Base64JsonStrategy,
DirectJsonStrategy,
type DecodingStrategy
} from '@immo24/decoder';
const chain = new DecodingStrategyChain()
.addStrategy(new Base64JsonStrategy())
.addStrategy(new DirectJsonStrategy());
const raw = chain.decode(encoded);Requirements
Node.js >= 16
License
CC-BY-NC-SA-4.0 — see LICENSE for details.
