herold-api-ts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,277 @@
1
+ # Herold.at API
2
+
3
+ A TypeScript library for scraping data from Herold.at Gelbe Seiten (Austrian yellow pages). This package provides functions to search business listings, fetch categories, extract contact information, and get detailed business information.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install hr-api-ts
9
+ # or
10
+ pnpm add hr-api-ts
11
+ # or
12
+ yarn add hr-api-ts
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Basic Import
18
+
19
+ ```typescript
20
+ import {
21
+ searchListings,
22
+ getEmailById,
23
+ getInfo,
24
+ getAutocompleteSuggestions,
25
+ } from "hr-api-ts";
26
+ ```
27
+
28
+ ### Search Business Listings
29
+
30
+ ```typescript
31
+ import { searchListings } from "hr-api-ts";
32
+
33
+ const result = await searchListings({
34
+ was: "arzt", // Search term (what to search for)
35
+ position: "20", // Position/offset
36
+ umkreis: "-1", // Radius (-1 = no limit)
37
+ anzahl: "10", // Number of results
38
+ sortierung: "relevanz", // Sort order: "relevanz", "name", "plz"
39
+ });
40
+
41
+ if (result.success) {
42
+ console.log(result.data); // Array of ListingResult
43
+ console.log(result.metadata); // Additional metadata
44
+ } else {
45
+ console.error(result.error);
46
+ }
47
+ ```
48
+
49
+ ### Get Detailed Business Information
50
+
51
+ ```typescript
52
+ import { getInfo } from "hr-api-ts";
53
+
54
+ const businessInfo = await getInfo("listing-id-here");
55
+
56
+ if (businessInfo.success) {
57
+ console.log("Business Name:", businessInfo.data.name);
58
+ console.log("Email:", businessInfo.data.email);
59
+ console.log("Phone:", businessInfo.data.phone);
60
+ console.log(
61
+ "Address:",
62
+ businessInfo.data.street,
63
+ businessInfo.data.plz,
64
+ businessInfo.data.city
65
+ );
66
+ console.log("Website:", businessInfo.data.website);
67
+ console.log("Fax:", businessInfo.data.fax);
68
+ } else {
69
+ console.error(businessInfo.error);
70
+ }
71
+ ```
72
+
73
+ ### Get Email by Listing ID
74
+
75
+ ```typescript
76
+ import { getEmailById } from "hr-api-ts";
77
+
78
+ const emailResult = await getEmailById("listing-id-here");
79
+
80
+ if (emailResult.success && emailResult.data) {
81
+ console.log("Email:", emailResult.data);
82
+ } else {
83
+ console.log("No email found or error occurred");
84
+ }
85
+ ```
86
+
87
+ ### Get Autocomplete Suggestions
88
+
89
+ ```typescript
90
+ import { getAutocompleteSuggestions } from "hr-api-ts";
91
+
92
+ const autocompleteResult = await getAutocompleteSuggestions("aut");
93
+
94
+ if (autocompleteResult.success) {
95
+ console.log("Suggestions:", autocompleteResult.data);
96
+ // Output: ["Auto", "Autoreparaturen", "Autoteile", "Autoverleih", ...]
97
+ } else {
98
+ console.error("Autocomplete failed:", autocompleteResult.error);
99
+ }
100
+ ```
101
+
102
+ ### Fetch Categories
103
+
104
+ ```typescript
105
+ import {
106
+ fetchCategoryNamesById,
107
+ fetchMainCategoryUrls,
108
+ fetchAllSubcategoryNames,
109
+ extractCategoryIdsFromUrl,
110
+ } from "hr-api-ts";
111
+
112
+ // Get category names by ID
113
+ const categories = await fetchCategoryNamesById("category-id");
114
+
115
+ // Get main category URLs
116
+ const mainCategories = await fetchMainCategoryUrls();
117
+
118
+ // Get all subcategory names
119
+ const allSubcategories = await fetchAllSubcategoryNames();
120
+
121
+ // Extract category IDs from a page URL
122
+ const categoryIds = await extractCategoryIdsFromUrl(
123
+ "https://www.herold.at/gelbe-seiten/branchenbuch"
124
+ );
125
+ ```
126
+
127
+ ## Types
128
+
129
+ ### ListingSearchParams
130
+
131
+ ```typescript
132
+ interface ListingSearchParams {
133
+ was?: string; // Search term
134
+ position?: string; // Position/offset
135
+ umkreis?: string; // Radius (-1 = no limit)
136
+ anzahl?: string; // Number of results
137
+ sortierung?: string; // Sort order
138
+ verwandt?: string; // Related search
139
+ }
140
+ ```
141
+
142
+ ### ListingResult
143
+
144
+ ```typescript
145
+ interface ListingResult {
146
+ id: string; // Unique listing ID
147
+ name: string; // Business name
148
+ website?: string; // Website URL (if available)
149
+ email?: string; // Email (if available)
150
+ }
151
+ ```
152
+
153
+ ### BusinessInfo
154
+
155
+ ```typescript
156
+ interface BusinessInfo {
157
+ name?: string; // Business name
158
+ email?: string; // Email address
159
+ street?: string; // Street address
160
+ city?: string; // City name
161
+ plz?: string; // Postal code
162
+ phone?: string; // Phone number
163
+ fax?: string; // Fax number
164
+ website?: string; // Website URL
165
+ }
166
+ ```
167
+
168
+ ### AutocompleteResponse
169
+
170
+ ```typescript
171
+ interface AutocompleteResponse {
172
+ vorschlaege: string[]; // Array of autocomplete suggestions
173
+ werbung: null; // Advertising field (always null)
174
+ }
175
+ ```
176
+
177
+ ### ScrapingResult
178
+
179
+ ```typescript
180
+ interface ScrapingResult<T> {
181
+ data: T;
182
+ success: boolean;
183
+ error?: string;
184
+ metadata?: {
185
+ anzahlTreffer?: number;
186
+ anzahlMehrTreffer?: number;
187
+ gesamtanzahlTreffer?: number;
188
+ };
189
+ }
190
+ ```
191
+
192
+ ## Available Functions
193
+
194
+ ### Core Functions
195
+
196
+ - `searchListings(params: ListingSearchParams)` - Search for business listings
197
+ - `getInfo(listingId: string)` - Get detailed business information (name, email, phone, address, website, fax)
198
+ - `getEmailById(listingId: string)` - Get email for a specific listing (backward compatibility)
199
+ - `getAutocompleteSuggestions(tag: string)` - Get autocomplete suggestions for search terms
200
+ - `fetchCategoryNamesById(categoryId: string)` - Get category names by ID
201
+ - `fetchMainCategoryUrls()` - Get main category URLs
202
+ - `extractCategoryIdsFromUrl(pageUrl: string)` - Extract category IDs from a page
203
+ - `fetchAllSubcategoryNames()` - Get all subcategory names
204
+
205
+ ### Aliases (for backward compatibility)
206
+
207
+ - `searchListingsByParams` - Alias for `searchListings`
208
+ - `getEmailByListingId` - Alias for `getEmailById`
209
+ - `getInfoByListingId` - Alias for `getInfo`
210
+ - `getCategorieNamesByID` - Alias for `fetchCategoryNamesById`
211
+ - `getMainCategories` - Alias for `fetchMainCategoryUrls`
212
+ - `getIdsByUrl` - Alias for `extractCategoryIdsFromUrl`
213
+ - `getAllSubcategories` - Alias for `fetchAllSubcategoryNames`
214
+
215
+ ## Example Usage
216
+
217
+ ```typescript
218
+ import { searchListings, getInfo, getAutocompleteSuggestions } from "hr-api-ts";
219
+
220
+ async function findAndGetBusinessInfo() {
221
+ // Get autocomplete suggestions first
222
+ const suggestions = await getAutocompleteSuggestions("arzt");
223
+ if (suggestions.success) {
224
+ console.log("Available suggestions:", suggestions.data);
225
+ }
226
+
227
+ // Search for doctors
228
+ const searchResult = await searchListings({
229
+ was: "arzt",
230
+ anzahl: "5",
231
+ sortierung: "relevanz",
232
+ });
233
+
234
+ if (searchResult.success && searchResult.data.length > 0) {
235
+ // Get detailed info for the first result
236
+ const firstListing = searchResult.data[0];
237
+ const businessInfo = await getInfo(firstListing.id);
238
+
239
+ if (businessInfo.success) {
240
+ console.log("Found business:", businessInfo.data);
241
+ }
242
+ }
243
+ }
244
+ ```
245
+
246
+ ## CLI Usage
247
+
248
+ You can also run the package directly as a CLI tool:
249
+
250
+ ```bash
251
+ # Build the project
252
+ pnpm build
253
+
254
+ # Run the example script
255
+ pnpm example
256
+ ```
257
+
258
+ ## Development
259
+
260
+ ```bash
261
+ # Install dependencies
262
+ pnpm install
263
+
264
+ # Run in development mode
265
+ pnpm dev
266
+
267
+ # Build for production
268
+ pnpm build
269
+ ```
270
+
271
+ ## License
272
+
273
+ ISC
274
+
275
+ ## Disclaimer
276
+
277
+ This library is for educational and research purposes. Please respect the terms of service of Herold.at and use this library responsibly. Make sure to comply with their robots.txt and rate limiting policies.
@@ -0,0 +1,17 @@
1
+ import { ScrapingResult, ListingSearchParams, ListingResult, BusinessInfo } from "./types";
2
+ export declare function fetchCategoryNamesById(categoryId: string): Promise<ScrapingResult<string[]>>;
3
+ export declare function fetchMainCategoryUrls(): Promise<ScrapingResult<string[]>>;
4
+ export declare function extractCategoryIdsFromUrl(pageUrl: string): Promise<ScrapingResult<string[]>>;
5
+ export declare function fetchAllSubcategoryNames(): Promise<ScrapingResult<string[]>>;
6
+ export declare const getCategorieNamesByID: typeof fetchCategoryNamesById;
7
+ export declare const getMainCategories: typeof fetchMainCategoryUrls;
8
+ export declare const getIdsByUrl: typeof extractCategoryIdsFromUrl;
9
+ export declare const getAllSubcategories: typeof fetchAllSubcategoryNames;
10
+ export declare const searchListingsByParams: typeof searchListings;
11
+ export declare const getInfoByListingId: typeof getInfo;
12
+ export declare function getEmailById(listingId: string): Promise<ScrapingResult<string | null>>;
13
+ export declare const getEmailByListingId: typeof getEmailById;
14
+ export declare function searchListings(params: ListingSearchParams): Promise<ScrapingResult<ListingResult[]>>;
15
+ export declare function getInfo(listingIdOrUrl: string): Promise<ScrapingResult<BusinessInfo>>;
16
+ export declare function getAutocompleteSuggestions(tag: string): Promise<ScrapingResult<string[]>>;
17
+ //# sourceMappingURL=gsHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gsHelper.d.ts","sourceRoot":"","sources":["../src/gsHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,aAAa,EAGb,YAAY,EAEb,MAAM,SAAS,CAAC;AAejB,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAsBnC;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CACpD,cAAc,CAAC,MAAM,EAAE,CAAC,CACzB,CA4BA;AAED,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAgCnC;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CACvD,cAAc,CAAC,MAAM,EAAE,CAAC,CACzB,CAiCA;AAED,eAAO,MAAM,qBAAqB,+BAAyB,CAAC;AAC5D,eAAO,MAAM,iBAAiB,8BAAwB,CAAC;AACvD,eAAO,MAAM,WAAW,kCAA4B,CAAC;AACrD,eAAO,MAAM,mBAAmB,iCAA2B,CAAC;AAC5D,eAAO,MAAM,sBAAsB,uBAAiB,CAAC;AACrD,eAAO,MAAM,kBAAkB,gBAAU,CAAC;AAE1C,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAMxC;AAED,eAAO,MAAM,mBAAmB,qBAAe,CAAC;AAUhD,wBAAsB,cAAc,CAClC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,CAAC,CA4F1C;AAED,wBAAsB,OAAO,CAC3B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CA8FvC;AAED,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAuCnC"}
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getEmailByListingId = exports.getInfoByListingId = exports.searchListingsByParams = exports.getAllSubcategories = exports.getIdsByUrl = exports.getMainCategories = exports.getCategorieNamesByID = void 0;
40
+ exports.fetchCategoryNamesById = fetchCategoryNamesById;
41
+ exports.fetchMainCategoryUrls = fetchMainCategoryUrls;
42
+ exports.extractCategoryIdsFromUrl = extractCategoryIdsFromUrl;
43
+ exports.fetchAllSubcategoryNames = fetchAllSubcategoryNames;
44
+ exports.getEmailById = getEmailById;
45
+ exports.searchListings = searchListings;
46
+ exports.getInfo = getInfo;
47
+ exports.getAutocompleteSuggestions = getAutocompleteSuggestions;
48
+ const cheerio = __importStar(require("cheerio"));
49
+ const axios_1 = __importDefault(require("axios"));
50
+ async function fetchHtml(url) {
51
+ try {
52
+ const response = await axios_1.default.get(url);
53
+ return response.data;
54
+ }
55
+ catch (error) {
56
+ throw new Error(`Failed to fetch ${url}: ${error instanceof Error ? error.message : "Unknown error"}`);
57
+ }
58
+ }
59
+ async function fetchCategoryNamesById(categoryId) {
60
+ try {
61
+ const url = `https://www.herold.at/gelbe-seiten/branchenbuch/rubriken/${categoryId}`;
62
+ const html = await fetchHtml(url);
63
+ const $ = cheerio.load(html);
64
+ const categoryNames = [];
65
+ $(".rubrik__list .table-grid__item a.link, .category-list a, .branchen-list a").each((_, element) => {
66
+ const categoryName = $(element).text().trim();
67
+ if (categoryName) {
68
+ categoryNames.push(categoryName);
69
+ }
70
+ });
71
+ return { data: categoryNames, success: true };
72
+ }
73
+ catch (error) {
74
+ return {
75
+ data: [],
76
+ success: false,
77
+ error: error instanceof Error ? error.message : "Unknown error",
78
+ };
79
+ }
80
+ }
81
+ async function fetchMainCategoryUrls() {
82
+ try {
83
+ const url = "https://www.herold.at/gelbe-seiten/branchenbuch";
84
+ const html = await fetchHtml(url);
85
+ const $ = cheerio.load(html);
86
+ const categoryUrls = [];
87
+ $(".citypages__country-pagesection-slider .gc-iconbox__link, .category-slider a, .main-categories a, .region-list a").each((_, element) => {
88
+ const href = $(element).attr("href");
89
+ if (href) {
90
+ const absoluteUrl = href.startsWith("http")
91
+ ? href
92
+ : `https://www.herold.at${href}`;
93
+ categoryUrls.push(absoluteUrl);
94
+ }
95
+ });
96
+ const uniqueUrls = [...new Set(categoryUrls)];
97
+ return { data: uniqueUrls, success: true };
98
+ }
99
+ catch (error) {
100
+ return {
101
+ data: [],
102
+ success: false,
103
+ error: error instanceof Error ? error.message : "Unknown error",
104
+ };
105
+ }
106
+ }
107
+ async function extractCategoryIdsFromUrl(pageUrl) {
108
+ try {
109
+ const html = await fetchHtml(pageUrl);
110
+ const $ = cheerio.load(html);
111
+ const urls = [];
112
+ $('.branchenseiten__grid a[href*="rubriken/"], .category-grid a[href*="rubriken/"], a[href*="/rubriken/"]').each((_, element) => {
113
+ const href = $(element).attr("href");
114
+ if (href) {
115
+ urls.push(href);
116
+ }
117
+ });
118
+ const ids = [
119
+ ...new Set(urls
120
+ .map((url) => {
121
+ const match = url.match(/rubriken\/(\d+)/);
122
+ return match ? match[1] : null;
123
+ })
124
+ .filter((id) => id !== null)),
125
+ ];
126
+ return { data: ids, success: true };
127
+ }
128
+ catch (error) {
129
+ return {
130
+ data: [],
131
+ success: false,
132
+ error: error instanceof Error ? error.message : "Unknown error",
133
+ };
134
+ }
135
+ }
136
+ async function fetchAllSubcategoryNames() {
137
+ try {
138
+ const mainCategoriesResult = await fetchMainCategoryUrls();
139
+ if (!mainCategoriesResult.success) {
140
+ return mainCategoriesResult;
141
+ }
142
+ const allCategoryNames = [];
143
+ const mainCategories = mainCategoriesResult.data;
144
+ for (const mainCategoryUrl of mainCategories) {
145
+ const idsResult = await extractCategoryIdsFromUrl(mainCategoryUrl);
146
+ if (!idsResult.success) {
147
+ continue;
148
+ }
149
+ for (const categoryId of idsResult.data) {
150
+ const categoryNamesResult = await fetchCategoryNamesById(categoryId);
151
+ if (categoryNamesResult.success) {
152
+ allCategoryNames.push(...categoryNamesResult.data);
153
+ }
154
+ }
155
+ }
156
+ const uniqueCategoryNames = [...new Set(allCategoryNames)];
157
+ return { data: uniqueCategoryNames, success: true };
158
+ }
159
+ catch (error) {
160
+ return {
161
+ data: [],
162
+ success: false,
163
+ error: error instanceof Error ? error.message : "Unknown error",
164
+ };
165
+ }
166
+ }
167
+ exports.getCategorieNamesByID = fetchCategoryNamesById;
168
+ exports.getMainCategories = fetchMainCategoryUrls;
169
+ exports.getIdsByUrl = extractCategoryIdsFromUrl;
170
+ exports.getAllSubcategories = fetchAllSubcategoryNames;
171
+ exports.searchListingsByParams = searchListings;
172
+ exports.getInfoByListingId = getInfo;
173
+ async function getEmailById(listingId) {
174
+ const result = await getInfo(listingId);
175
+ if (result.success) {
176
+ return { data: result.data.email || null, success: true };
177
+ }
178
+ return { data: null, success: false, error: result.error };
179
+ }
180
+ exports.getEmailByListingId = getEmailById;
181
+ function decodeBase64(str) {
182
+ try {
183
+ return Buffer.from(str, "base64").toString("utf-8");
184
+ }
185
+ catch (error) {
186
+ return "";
187
+ }
188
+ }
189
+ async function searchListings(params) {
190
+ try {
191
+ const searchParams = new URLSearchParams();
192
+ if (params.was) {
193
+ searchParams.append("term", params.was);
194
+ }
195
+ const page = params.position ? Math.floor(parseInt(params.position) / 20) + 1 : 1;
196
+ if (page > 1) {
197
+ searchParams.append("seite", page.toString());
198
+ }
199
+ if (params.umkreis && params.umkreis !== "-1") {
200
+ searchParams.append("umkreis", params.umkreis);
201
+ }
202
+ if (params.sortierung) {
203
+ searchParams.append("sortierung", params.sortierung);
204
+ }
205
+ const searchUrl = `https://www.herold.at/gelbe-seiten/suche/?${searchParams.toString()}`;
206
+ const html = await fetchHtml(searchUrl);
207
+ const $ = cheerio.load(html);
208
+ const listings = [];
209
+ $("li.location-search-result, li[itemProp='itemListElement']").each((_, element) => {
210
+ const $element = $(element);
211
+ const article = $element.find("article[itemScope]").first();
212
+ if (!article.length)
213
+ return;
214
+ const detailLink = article.find('a[href*="/gelbe-seiten/"]').first();
215
+ if (!detailLink.length)
216
+ return;
217
+ const href = detailLink.attr("href") || "";
218
+ const listingIdMatch = href.match(/\/gelbe-seiten\/[^\/]+\/([^\/]+)\//);
219
+ const listingId = listingIdMatch ? listingIdMatch[1] :
220
+ article.find('meta[itemProp="identifier"]').attr("content") ||
221
+ "";
222
+ if (!listingId)
223
+ return;
224
+ let listingName = article.find('meta[itemProp="name"]').attr("content") ||
225
+ article.find("h2, h3, h4, a[itemProp='url'] span").first().text().trim();
226
+ if (!listingName) {
227
+ listingName = detailLink.text().trim();
228
+ }
229
+ if (!listingName) {
230
+ listingName = article.find("a").first().text().trim();
231
+ }
232
+ const listing = {
233
+ id: listingId,
234
+ name: listingName || "Unknown",
235
+ detailUrl: href.startsWith("http") ? href : `https://www.herold.at${href}`,
236
+ };
237
+ const websiteLink = article.find('a[href^="http"]:not([href*="herold.at"])').first();
238
+ if (websiteLink.length) {
239
+ const website = websiteLink.attr("href");
240
+ if (website && website.startsWith("http")) {
241
+ listing.website = website;
242
+ }
243
+ }
244
+ listings.push(listing);
245
+ });
246
+ const metadata = {};
247
+ const resultCountText = $("h1, .result-count, .anzahl-treffer, .search-results-count").text();
248
+ const countMatch = resultCountText.match(/(\d+)\s+Ergebnisse/);
249
+ if (countMatch) {
250
+ metadata.gesamtanzahlTreffer = parseInt(countMatch[1], 10);
251
+ metadata.anzahlTreffer = listings.length;
252
+ }
253
+ return {
254
+ data: listings,
255
+ success: true,
256
+ metadata: Object.keys(metadata).length > 0 ? metadata : undefined,
257
+ };
258
+ }
259
+ catch (error) {
260
+ return {
261
+ data: [],
262
+ success: false,
263
+ error: error instanceof Error ? error.message : "Unknown error",
264
+ };
265
+ }
266
+ }
267
+ async function getInfo(listingIdOrUrl) {
268
+ try {
269
+ let url;
270
+ if (listingIdOrUrl.startsWith("http")) {
271
+ url = listingIdOrUrl;
272
+ }
273
+ else {
274
+ url = `https://www.herold.at/gelbe-seiten/firma/${listingIdOrUrl}`;
275
+ }
276
+ const html = await fetchHtml(url);
277
+ const $ = cheerio.load(html);
278
+ const businessInfo = {};
279
+ const nameElement = $(".firmen-name, .company-name, .mod-Kontaktdaten__container .gc-text--h2, h1, .business-name");
280
+ if (nameElement.length > 0) {
281
+ businessInfo.name = nameElement.first().text().trim();
282
+ }
283
+ const emailButton = $("#email_versenden, .email-button, [data-email], a[href^='mailto:']");
284
+ if (emailButton.length > 0) {
285
+ const dataLink = emailButton.attr("data-link") || emailButton.attr("href") || emailButton.attr("data-email");
286
+ if (dataLink && dataLink.startsWith("mailto:")) {
287
+ const email = dataLink.replace("mailto:", "").split("?")[0];
288
+ businessInfo.email = email;
289
+ }
290
+ else if (dataLink && dataLink.includes("@")) {
291
+ businessInfo.email = dataLink;
292
+ }
293
+ }
294
+ const streetAddress = $('meta[itemProp="streetAddress"]').attr("content");
295
+ const postalCode = $('meta[itemProp="postalCode"]').attr("content");
296
+ const addressRegion = $('meta[itemProp="addressRegion"]').attr("content");
297
+ if (streetAddress) {
298
+ businessInfo.street = streetAddress;
299
+ }
300
+ if (postalCode) {
301
+ businessInfo.plz = postalCode;
302
+ }
303
+ if (addressRegion) {
304
+ businessInfo.city = addressRegion;
305
+ }
306
+ if (!businessInfo.street || !businessInfo.city) {
307
+ const addressContainer = $(".address, .adresse, .mod-Kontaktdaten__address-container, .contact-address, [itemProp='address']");
308
+ if (addressContainer.length > 0) {
309
+ const addressText = addressContainer.find(".adresse-text, .address-text, .street-address, span").first();
310
+ if (addressText.length > 0) {
311
+ const fullAddress = addressText.text().trim();
312
+ const addressMatch = fullAddress.match(/^(.+?)\s+(\d{4,5})\s+(.+)$/);
313
+ if (addressMatch) {
314
+ if (!businessInfo.street)
315
+ businessInfo.street = addressMatch[1];
316
+ if (!businessInfo.plz)
317
+ businessInfo.plz = addressMatch[2];
318
+ if (!businessInfo.city)
319
+ businessInfo.city = addressMatch[3];
320
+ }
321
+ }
322
+ }
323
+ }
324
+ const phoneElement = $('.phone, .telefon, .mod-Kontaktdaten__list-item.contains-icon-big-tel span[data-role="telefonnummer"] a, [data-phone], a[href^="tel:"]');
325
+ if (phoneElement.length > 0) {
326
+ const phoneText = phoneElement.text().trim() || phoneElement.attr("href")?.replace("tel:", "");
327
+ if (phoneText) {
328
+ businessInfo.phone = phoneText;
329
+ }
330
+ }
331
+ const faxElement = $(".fax, .mod-Kontaktdaten__list-item.contains-icon-big-fax span, [data-fax]");
332
+ if (faxElement.length > 0) {
333
+ businessInfo.fax = faxElement.text().trim();
334
+ }
335
+ const websiteElement = $(".website, .homepage, .mod-Kontaktdaten__list-item.contains-icon-big-homepage a, [data-website], a[href^='http']");
336
+ if (websiteElement.length > 0) {
337
+ const website = websiteElement.attr("href");
338
+ if (website && website.startsWith("http")) {
339
+ businessInfo.website = website;
340
+ }
341
+ }
342
+ return { data: businessInfo, success: true };
343
+ }
344
+ catch (error) {
345
+ return {
346
+ data: {},
347
+ success: false,
348
+ error: error instanceof Error ? error.message : "Unknown error",
349
+ };
350
+ }
351
+ }
352
+ async function getAutocompleteSuggestions(tag) {
353
+ try {
354
+ const url = `https://www.herold.at/gelbe-seiten/vorschlagsliste/was?opposite=&tag=${encodeURIComponent(tag)}`;
355
+ try {
356
+ const response = await axios_1.default.get(url);
357
+ if (response.data && typeof response.data === 'object' && 'vorschlaege' in response.data) {
358
+ const data = response.data;
359
+ return { data: data.vorschlaege, success: true };
360
+ }
361
+ }
362
+ catch (apiError) {
363
+ }
364
+ const searchUrl = `https://www.herold.at/gelbe-seiten/suche/?term=${encodeURIComponent(tag)}`;
365
+ const html = await fetchHtml(searchUrl);
366
+ const $ = cheerio.load(html);
367
+ const suggestions = [];
368
+ $(".autocomplete-suggestion, .suggestion-item, .search-suggestion, [data-suggestion], .related-branches a, .verwandte-branchen a").each((_, element) => {
369
+ const suggestion = $(element).text().trim();
370
+ if (suggestion) {
371
+ suggestions.push(suggestion);
372
+ }
373
+ });
374
+ if (suggestions.length > 0) {
375
+ return { data: suggestions, success: true };
376
+ }
377
+ return { data: [], success: true };
378
+ }
379
+ catch (error) {
380
+ return {
381
+ data: [],
382
+ success: false,
383
+ error: error instanceof Error ? error.message : "Unknown error",
384
+ };
385
+ }
386
+ }
387
+ //# sourceMappingURL=gsHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gsHelper.js","sourceRoot":"","sources":["../src/gsHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,wDAwBC;AAED,sDA8BC;AAED,8DAkCC;AAED,4DAmCC;AASD,oCAQC;AAYD,wCA8FC;AAED,0BAgGC;AAED,gEAyCC;AAlaD,iDAAmC;AACnC,kDAA0B;AAW1B,KAAK,UAAU,SAAS,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,mBAAmB,GAAG,KACpB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAC3C,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,UAAkB;IAElB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,4DAA4D,UAAU,EAAE,CAAC;QACrF,MAAM,IAAI,GAAG,MAAM,S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,EAAE,CAAC;YAC5C,IAAI,UAAU,EAAE,CAAC;gBACf,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC9C,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,EAAE;YACR,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { fetchCategoryNamesById, fetchMainCategoryUrls, extractCategoryIdsFromUrl, fetchAllSubcategoryNames, searchListings, getEmailById, getInfo, getCategorieNamesByID, getMainCategories, getIdsByUrl, getAllSubcategories, searchListingsByParams, getEmailByListingId, getInfoByListingId, getAutocompleteSuggestions, } from "./gsHelper";
2
+ export type { ScrapingResult, ListingSearchParams, ListingResult, BusinessInfo, AjaxSearchResponse, WipePageItem, AutocompleteResponse, } from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,OAAO,EACP,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAutocompleteSuggestions = exports.getInfoByListingId = exports.getEmailByListingId = exports.searchListingsByParams = exports.getAllSubcategories = exports.getIdsByUrl = exports.getMainCategories = exports.getCategorieNamesByID = exports.getInfo = exports.getEmailById = exports.searchListings = exports.fetchAllSubcategoryNames = exports.extractCategoryIdsFromUrl = exports.fetchMainCategoryUrls = exports.fetchCategoryNamesById = void 0;
4
+ var gsHelper_1 = require("./gsHelper");
5
+ Object.defineProperty(exports, "fetchCategoryNamesById", { enumerable: true, get: function () { return gsHelper_1.fetchCategoryNamesById; } });
6
+ Object.defineProperty(exports, "fetchMainCategoryUrls", { enumerable: true, get: function () { return gsHelper_1.fetchMainCategoryUrls; } });
7
+ Object.defineProperty(exports, "extractCategoryIdsFromUrl", { enumerable: true, get: function () { return gsHelper_1.extractCategoryIdsFromUrl; } });
8
+ Object.defineProperty(exports, "fetchAllSubcategoryNames", { enumerable: true, get: function () { return gsHelper_1.fetchAllSubcategoryNames; } });
9
+ Object.defineProperty(exports, "searchListings", { enumerable: true, get: function () { return gsHelper_1.searchListings; } });
10
+ Object.defineProperty(exports, "getEmailById", { enumerable: true, get: function () { return gsHelper_1.getEmailById; } });
11
+ Object.defineProperty(exports, "getInfo", { enumerable: true, get: function () { return gsHelper_1.getInfo; } });
12
+ Object.defineProperty(exports, "getCategorieNamesByID", { enumerable: true, get: function () { return gsHelper_1.getCategorieNamesByID; } });
13
+ Object.defineProperty(exports, "getMainCategories", { enumerable: true, get: function () { return gsHelper_1.getMainCategories; } });
14
+ Object.defineProperty(exports, "getIdsByUrl", { enumerable: true, get: function () { return gsHelper_1.getIdsByUrl; } });
15
+ Object.defineProperty(exports, "getAllSubcategories", { enumerable: true, get: function () { return gsHelper_1.getAllSubcategories; } });
16
+ Object.defineProperty(exports, "searchListingsByParams", { enumerable: true, get: function () { return gsHelper_1.searchListingsByParams; } });
17
+ Object.defineProperty(exports, "getEmailByListingId", { enumerable: true, get: function () { return gsHelper_1.getEmailByListingId; } });
18
+ Object.defineProperty(exports, "getInfoByListingId", { enumerable: true, get: function () { return gsHelper_1.getInfoByListingId; } });
19
+ Object.defineProperty(exports, "getAutocompleteSuggestions", { enumerable: true, get: function () { return gsHelper_1.getAutocompleteSuggestions; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAgBoB;AAflB,kHAAA,sBAAsB,OAAA;AACtB,iHAAA,qBAAqB,OAAA;AACrB,qHAAA,yBAAyB,OAAA;AACzB,oHAAA,wBAAwB,OAAA;AACxB,0GAAA,cAAc,OAAA;AACd,wGAAA,YAAY,OAAA;AACZ,mGAAA,OAAO,OAAA;AACP,iHAAA,qBAAqB,OAAA;AACrB,6GAAA,iBAAiB,OAAA;AACjB,uGAAA,WAAW,OAAA;AACX,+GAAA,mBAAmB,OAAA;AACnB,kHAAA,sBAAsB,OAAA;AACtB,+GAAA,mBAAmB,OAAA;AACnB,8GAAA,kBAAkB,OAAA;AAClB,sHAAA,0BAA0B,OAAA"}
@@ -0,0 +1,60 @@
1
+ export interface ScrapingResult<T> {
2
+ data: T;
3
+ success: boolean;
4
+ error?: string;
5
+ metadata?: {
6
+ anzahlTreffer?: number;
7
+ anzahlMehrTreffer?: number;
8
+ gesamtanzahlTreffer?: number;
9
+ };
10
+ }
11
+ export interface ListingSearchParams {
12
+ was?: string;
13
+ position?: string;
14
+ umkreis?: string;
15
+ anzahl?: string;
16
+ sortierung?: string;
17
+ verwandt?: string;
18
+ }
19
+ export interface ListingResult {
20
+ id: string;
21
+ name: string;
22
+ website?: string;
23
+ email?: string;
24
+ detailUrl?: string;
25
+ }
26
+ export interface BusinessInfo {
27
+ name?: string;
28
+ email?: string;
29
+ street?: string;
30
+ city?: string;
31
+ plz?: string;
32
+ phone?: string;
33
+ fax?: string;
34
+ website?: string;
35
+ }
36
+ export interface AjaxSearchResponse {
37
+ anzahlTreffer: number;
38
+ anzahlMehrTreffer: number;
39
+ gesamtanzahlTreffer: number;
40
+ wipePageItemsJson: string;
41
+ html: string;
42
+ karteVorschauUrl: string;
43
+ koordinatenFuerGrosseKarte: string;
44
+ }
45
+ export interface WipePageItem {
46
+ na: string;
47
+ oat: string;
48
+ pos: string;
49
+ ttf: string;
50
+ bi: string;
51
+ id: string;
52
+ oid: string;
53
+ pn: string;
54
+ cid: string;
55
+ }
56
+ export interface AutocompleteResponse {
57
+ vorschlaege: string[];
58
+ werbung: null;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE;QACT,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;CACH;AAED,MAAM,WAAW,mBAAmB;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,0BAA0B,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,IAAI,CAAC;CACf"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "herold-api-ts",
3
+ "version": "1.0.0",
4
+ "description": "hr-api-ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/**/*",
16
+ "README.md"
17
+ ],
18
+ "author": "osbeer",
19
+ "license": "ISC",
20
+ "dependencies": {
21
+ "axios": "^1.12.2",
22
+ "cheerio": "^1.1.2"
23
+ },
24
+ "devDependencies": {
25
+ "@types/node": "^20.19.21",
26
+ "ts-node": "^10.9.2",
27
+ "typescript": "^5.9.3"
28
+ },
29
+ "engines": {
30
+ "node": ">=16.0.0"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc",
34
+ "start": "node dist/index.js",
35
+ "dev": "ts-node src/index.ts",
36
+ "example": "ts-node example/example.ts"
37
+ }
38
+ }