atlas-obscura-api 5.1.0 → 5.2.1
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 +45 -0
- package/atlas-obscura-uP0eMlIt.d.ts +96 -0
- package/index.d.ts +3 -108
- package/index.fetch.d.ts +3 -0
- package/index.fetch.js +41 -0
- package/index.fetch.js.map +1 -0
- package/index.js +7 -102
- package/index.js.map +1 -1
- package/location.service-CR5JY1Ij.js +138 -0
- package/location.service-CR5JY1Ij.js.map +1 -0
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -28,6 +28,13 @@ Install the library using npm, yarn, or your preferred package manager:
|
|
|
28
28
|
npm install atlas-obscura-api --save
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
### Node.js vs. React Native / browser
|
|
32
|
+
|
|
33
|
+
The import is the same everywhere. Node.js gets a build that fetches with
|
|
34
|
+
[got-scraping](https://github.com/apify/got-scraping). React Native (Metro) and browser bundlers pick a
|
|
35
|
+
build that uses plain `fetch` through the `react-native` and `browser` export conditions, so got-scraping
|
|
36
|
+
never ends up in a mobile or web bundle.
|
|
37
|
+
|
|
31
38
|
## 🚀 Usage and Examples
|
|
32
39
|
|
|
33
40
|
Explore how to use the library with practical code snippets and sample outputs below:
|
|
@@ -46,6 +53,9 @@ Explore how to use the library with practical code snippets and sample outputs b
|
|
|
46
53
|
import { atlasObscura } from 'atlas-obscura-api';
|
|
47
54
|
|
|
48
55
|
atlasObscura.placesAll().then((places) => console.log(places));
|
|
56
|
+
|
|
57
|
+
// const places = await atlasObscura.placesAll();
|
|
58
|
+
// console.log(places);
|
|
49
59
|
```
|
|
50
60
|
|
|
51
61
|
#### Results
|
|
@@ -75,6 +85,9 @@ atlasObscura.placesAll().then((places) => console.log(places));
|
|
|
75
85
|
import { atlasObscura } from 'atlas-obscura-api';
|
|
76
86
|
|
|
77
87
|
atlasObscura.search({ lat: 34.0522, lng: -118.2437 }).then((search) => console.log(search));
|
|
88
|
+
|
|
89
|
+
// const search = await atlasObscura.search({ lat: 34.0522, lng: -118.2437 });
|
|
90
|
+
// console.log(search);
|
|
78
91
|
```
|
|
79
92
|
|
|
80
93
|
#### Results
|
|
@@ -132,6 +145,9 @@ atlasObscura.search({ lat: 34.0522, lng: -118.2437 }).then((search) => console.l
|
|
|
132
145
|
import { atlasObscura } from 'atlas-obscura-api';
|
|
133
146
|
|
|
134
147
|
atlasObscura.placeShort(494).then((place) => console.log(place));
|
|
148
|
+
|
|
149
|
+
// const place = await atlasObscura.placeShort(494);
|
|
150
|
+
// console.log(place);
|
|
135
151
|
```
|
|
136
152
|
|
|
137
153
|
#### Results
|
|
@@ -165,6 +181,9 @@ atlasObscura.placeShort(494).then((place) => console.log(place));
|
|
|
165
181
|
import { atlasObscura } from 'atlas-obscura-api';
|
|
166
182
|
|
|
167
183
|
atlasObscura.placeFull(494).then((place) => console.log(place));
|
|
184
|
+
|
|
185
|
+
// const place = await atlasObscura.placeFull(494);
|
|
186
|
+
// console.log(place);
|
|
168
187
|
```
|
|
169
188
|
|
|
170
189
|
#### Results
|
|
@@ -221,6 +240,9 @@ atlasObscura.placeFull(494).then((place) => console.log(place));
|
|
|
221
240
|
import { atlasObscura } from 'atlas-obscura-api';
|
|
222
241
|
|
|
223
242
|
atlasObscura.user('bartholomej').then((user) => console.log(user));
|
|
243
|
+
|
|
244
|
+
// const user = await atlasObscura.user('bartholomej');
|
|
245
|
+
// console.log(user);
|
|
224
246
|
```
|
|
225
247
|
|
|
226
248
|
#### Results
|
|
@@ -307,6 +329,29 @@ docker run -p 3000:3000 atlas-obscura-api
|
|
|
307
329
|
- `/place-full/456`
|
|
308
330
|
- `/user/bartholomej`
|
|
309
331
|
|
|
332
|
+
Upstream failures answer `502` with a JSON error, never a `200` with `null`.
|
|
333
|
+
|
|
334
|
+
## ☁️ Server: Node.js or Cloudflare Workers
|
|
335
|
+
|
|
336
|
+
The REST server is a [Hono](https://hono.dev) app (`server/app.ts`) with two entry points:
|
|
337
|
+
|
|
338
|
+
- `server/node.ts` runs on Node.js (`yarn server`, Docker) and fetches with got-scraping.
|
|
339
|
+
- `server/worker.ts` runs on Cloudflare Workers (`yarn worker:dev`, `yarn worker:deploy`) and fetches with
|
|
340
|
+
plain `fetch`. Responses are cached at the edge with the Cache API: `/places-all` for 12 hours,
|
|
341
|
+
`/place-full` and `/place-short` for 24 hours, search and user for 1 hour (set in `server/app.ts`).
|
|
342
|
+
|
|
343
|
+
Configuration is the same in both: `API_KEY`, `API_KEY_NAME`, `CORS_ORIGINS` (comma separated, `*` for
|
|
344
|
+
any) and `VERBOSE`. On Workers, put `API_KEY` in a secret (`npx wrangler secret put API_KEY`) and the rest,
|
|
345
|
+
if you need it, in `vars` in `wrangler.jsonc`.
|
|
346
|
+
|
|
347
|
+
When `API_KEY` is set, send it as `Authorization: Bearer <key>`. The Worker accepts only that. The Node.js
|
|
348
|
+
server (Docker) also accepts the `API_KEY_NAME` header (`x-api-key` by default) for older clients; it is
|
|
349
|
+
deprecated and will be removed in the next major version.
|
|
350
|
+
|
|
351
|
+
```bash
|
|
352
|
+
curl -H "Authorization: Bearer $API_KEY" https://your-server/places-all
|
|
353
|
+
```
|
|
354
|
+
|
|
310
355
|
## Used By
|
|
311
356
|
|
|
312
357
|
- Mobile app: Atlas Obscura: Offline → [Play Store](https://play.google.com/store/apps/details?id=com.aquasoup.atlasobscura)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
interface AOCoordinates {
|
|
2
|
+
lat: number;
|
|
3
|
+
lng: number;
|
|
4
|
+
}
|
|
5
|
+
type AOFetchOptions = {
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
interface AOLocationResult {
|
|
9
|
+
total: AOTotal;
|
|
10
|
+
per_page: number;
|
|
11
|
+
current_page: number;
|
|
12
|
+
location: string;
|
|
13
|
+
q: string;
|
|
14
|
+
coordinates: AOCoordinates;
|
|
15
|
+
results: AOLocation[];
|
|
16
|
+
}
|
|
17
|
+
interface AOLocation {
|
|
18
|
+
title: string;
|
|
19
|
+
subtitle: string;
|
|
20
|
+
location: string;
|
|
21
|
+
thumbnail_url: string;
|
|
22
|
+
url: string;
|
|
23
|
+
id: number;
|
|
24
|
+
hide_from_maps?: string;
|
|
25
|
+
coordinates: AOCoordinates;
|
|
26
|
+
distance_from_query: string;
|
|
27
|
+
}
|
|
28
|
+
interface AOTotal {
|
|
29
|
+
value: number;
|
|
30
|
+
relation: string;
|
|
31
|
+
}
|
|
32
|
+
interface AOPlaceShort {
|
|
33
|
+
id: number;
|
|
34
|
+
title: string;
|
|
35
|
+
subtitle: string;
|
|
36
|
+
city: string;
|
|
37
|
+
country: string;
|
|
38
|
+
location: string;
|
|
39
|
+
url: string;
|
|
40
|
+
hide_from_maps?: boolean;
|
|
41
|
+
physical_status: string;
|
|
42
|
+
thumbnail_url: string;
|
|
43
|
+
thumbnail_url_3x2: string;
|
|
44
|
+
coordinates: AOCoordinates;
|
|
45
|
+
nearby_places: AOPlaceShort[];
|
|
46
|
+
nearby_foods: AOPlaceShort[];
|
|
47
|
+
}
|
|
48
|
+
interface AOPlaceExtend {
|
|
49
|
+
description?: string[];
|
|
50
|
+
tags?: AOTag[];
|
|
51
|
+
directions?: string[];
|
|
52
|
+
imageCover?: string;
|
|
53
|
+
images?: string[];
|
|
54
|
+
}
|
|
55
|
+
interface AOTag {
|
|
56
|
+
title: string;
|
|
57
|
+
link: string;
|
|
58
|
+
}
|
|
59
|
+
interface AOPlace extends AOPlaceShort, AOPlaceExtend {}
|
|
60
|
+
interface AOPlacesAll extends AOCoordinates {
|
|
61
|
+
id: number;
|
|
62
|
+
}
|
|
63
|
+
interface AOUser {
|
|
64
|
+
id: number;
|
|
65
|
+
places: AOUserPlace[];
|
|
66
|
+
}
|
|
67
|
+
interface AOUserPlace {
|
|
68
|
+
id: number;
|
|
69
|
+
title: string;
|
|
70
|
+
subtitle: string;
|
|
71
|
+
url: string;
|
|
72
|
+
location: string;
|
|
73
|
+
thumbnail_url: string;
|
|
74
|
+
coordinates: AOCoordinates;
|
|
75
|
+
}
|
|
76
|
+
/** Returns the response body, or the string `'Error'` when the request failed. */
|
|
77
|
+
type FetchPage = (url: string, headers?: Record<string, string>) => Promise<string>;
|
|
78
|
+
declare class PlacesScraper {
|
|
79
|
+
private readonly fetchPage;
|
|
80
|
+
constructor(fetchPage: FetchPage);
|
|
81
|
+
placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]>;
|
|
82
|
+
search(coords: AOCoordinates, page?: number, options?: AOFetchOptions): Promise<AOLocationResult>;
|
|
83
|
+
placeByIdShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort>;
|
|
84
|
+
placeFull(url: string, options?: AOFetchOptions): Promise<AOPlaceExtend>;
|
|
85
|
+
user(user: string, options?: AOFetchOptions): Promise<AOUser>;
|
|
86
|
+
}
|
|
87
|
+
declare class AtlasObscura {
|
|
88
|
+
private locationService;
|
|
89
|
+
constructor(locationService: PlacesScraper);
|
|
90
|
+
search(coords: AOCoordinates, options?: AOFetchOptions): Promise<AOLocationResult>;
|
|
91
|
+
placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]>;
|
|
92
|
+
placeShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort>;
|
|
93
|
+
placeFull(id: number, options?: AOFetchOptions): Promise<AOPlace>;
|
|
94
|
+
user(user: string, options?: AOFetchOptions): Promise<AOUser>;
|
|
95
|
+
}
|
|
96
|
+
export { AOPlaceShort as a, AOLocationResult as c, AOFetchOptions as d, AOPlaceExtend as i, AOTotal as l, AOPlacesAll as n, AOTag as o, AOPlace as r, AOLocation as s, AtlasObscura as t, AOCoordinates as u };
|
package/index.d.ts
CHANGED
|
@@ -1,108 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
lng: number;
|
|
5
|
-
}
|
|
6
|
-
type AOFetchOptions = {
|
|
7
|
-
headers?: Headers;
|
|
8
|
-
};
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/interfaces/locations.interface.d.ts
|
|
11
|
-
interface AOLocationResult {
|
|
12
|
-
total: AOTotal;
|
|
13
|
-
per_page: number;
|
|
14
|
-
current_page: number;
|
|
15
|
-
location: string;
|
|
16
|
-
q: string;
|
|
17
|
-
coordinates: AOCoordinates;
|
|
18
|
-
results: AOLocation[];
|
|
19
|
-
}
|
|
20
|
-
interface AOLocation {
|
|
21
|
-
title: string;
|
|
22
|
-
subtitle: string;
|
|
23
|
-
location: string;
|
|
24
|
-
thumbnail_url: string;
|
|
25
|
-
url: string;
|
|
26
|
-
id: number;
|
|
27
|
-
hide_from_maps?: string;
|
|
28
|
-
coordinates: AOCoordinates;
|
|
29
|
-
distance_from_query: string;
|
|
30
|
-
}
|
|
31
|
-
interface AOTotal {
|
|
32
|
-
value: number;
|
|
33
|
-
relation: string;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/interfaces/placeId.interface.d.ts
|
|
37
|
-
interface AOPlaceShort {
|
|
38
|
-
id: number;
|
|
39
|
-
title: string;
|
|
40
|
-
subtitle: string;
|
|
41
|
-
city: string;
|
|
42
|
-
country: string;
|
|
43
|
-
location: string;
|
|
44
|
-
url: string;
|
|
45
|
-
hide_from_maps?: string;
|
|
46
|
-
physical_status: string;
|
|
47
|
-
thumbnail_url: string;
|
|
48
|
-
thumbnail_url_3x2: string;
|
|
49
|
-
coordinates: AOCoordinates;
|
|
50
|
-
nearby_places: AOPlaceShort[];
|
|
51
|
-
nearby_foods: AOPlaceShort[];
|
|
52
|
-
}
|
|
53
|
-
interface AOPlaceExtend {
|
|
54
|
-
description?: string[];
|
|
55
|
-
tags?: AOTag[];
|
|
56
|
-
directions?: string[];
|
|
57
|
-
imageCover?: string;
|
|
58
|
-
images?: string[];
|
|
59
|
-
}
|
|
60
|
-
interface AOTag {
|
|
61
|
-
title: string;
|
|
62
|
-
link: string;
|
|
63
|
-
}
|
|
64
|
-
interface AOPlace extends AOPlaceShort, AOPlaceExtend {}
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region src/interfaces/places-all.interface.d.ts
|
|
67
|
-
interface AOPlacesAll extends AOCoordinates {
|
|
68
|
-
id: number;
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/interfaces/user.interface.d.ts
|
|
72
|
-
interface AOUser {
|
|
73
|
-
id: number;
|
|
74
|
-
places: AOUserPlace[];
|
|
75
|
-
}
|
|
76
|
-
interface AOUserPlace {
|
|
77
|
-
id: number;
|
|
78
|
-
title: string;
|
|
79
|
-
subtitle: string;
|
|
80
|
-
url: string;
|
|
81
|
-
location: string;
|
|
82
|
-
thumbnail_url: string;
|
|
83
|
-
coordinates: AOCoordinates;
|
|
84
|
-
}
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/services/location.service.d.ts
|
|
87
|
-
declare class PlacesScraper {
|
|
88
|
-
placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]>;
|
|
89
|
-
search(coords: AOCoordinates, page?: number, options?: AOFetchOptions): Promise<AOLocationResult>;
|
|
90
|
-
placeByIdShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort>;
|
|
91
|
-
placeFull(url: string, options?: AOFetchOptions): Promise<AOPlaceExtend>;
|
|
92
|
-
user(user: string, options?: AOFetchOptions): Promise<AOUser>;
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/index.d.ts
|
|
96
|
-
declare class AtlasObscura {
|
|
97
|
-
private locationService;
|
|
98
|
-
constructor(locationService: PlacesScraper);
|
|
99
|
-
search(coords: AOCoordinates, options?: AOFetchOptions): Promise<AOLocationResult>;
|
|
100
|
-
placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]>;
|
|
101
|
-
placeShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort>;
|
|
102
|
-
placeFull(id: number, options?: AOFetchOptions): Promise<AOPlace>;
|
|
103
|
-
user(user: string, options?: AOFetchOptions): Promise<AOUser>;
|
|
104
|
-
}
|
|
105
|
-
declare const atlasObscura: AtlasObscura;
|
|
106
|
-
//#endregion
|
|
107
|
-
export { type AOCoordinates, type AOFetchOptions, type AOLocation, type AOLocationResult, type AOPlace, type AOPlaceExtend, type AOPlaceShort, type AOPlacesAll, type AOTag, type AOTotal, AtlasObscura, atlasObscura };
|
|
108
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { a as AOPlaceShort, c as AOLocationResult, d as AOFetchOptions, i as AOPlaceExtend, l as AOTotal, n as AOPlacesAll, o as AOTag, r as AOPlace, s as AOLocation, t as AtlasObscura, u as AOCoordinates } from "./atlas-obscura-uP0eMlIt.js";
|
|
2
|
+
export declare const atlasObscura: AtlasObscura;
|
|
3
|
+
export { type AOCoordinates, type AOFetchOptions, type AOLocation, type AOLocationResult, type AOPlace, type AOPlaceExtend, type AOPlaceShort, type AOPlacesAll, type AOTag, type AOTotal, AtlasObscura };
|
package/index.fetch.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as AOPlaceShort, c as AOLocationResult, d as AOFetchOptions, i as AOPlaceExtend, l as AOTotal, n as AOPlacesAll, o as AOTag, r as AOPlace, s as AOLocation, t as AtlasObscura, u as AOCoordinates } from "./atlas-obscura-uP0eMlIt.js";
|
|
2
|
+
export declare const atlasObscura: AtlasObscura;
|
|
3
|
+
export { type AOCoordinates, type AOFetchOptions, type AOLocation, type AOLocationResult, type AOPlace, type AOPlaceExtend, type AOPlaceShort, type AOPlacesAll, type AOTag, type AOTotal, AtlasObscura };
|
package/index.fetch.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as AtlasObscura, t as PlacesScraper } from "./location.service-CR5JY1Ij.js";
|
|
2
|
+
// src/fetchers/fetch.ts
|
|
3
|
+
const USER_AGENTS = [
|
|
4
|
+
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; C6L Build/OPM2.171019.012)",
|
|
5
|
+
"Mozilla/5.0 (Windows; Windows NT 10.0; x64) AppleWebKit/537.50 (KHTML, like Gecko) Chrome/48.0.2572.385 Safari/537.9 Edge/8.37913",
|
|
6
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14E5239e Safari/602.1",
|
|
7
|
+
"Dalvik/2.1.0 (Linux; U; Android 11; SM-A505GT Build/RP1A.200720.012)",
|
|
8
|
+
"Mozilla/5.0 (Windows NT 10.3;; en-US) AppleWebKit/602.25 (KHTML, like Gecko) Chrome/54.0.2457.241 Safari/534.5 Edge/9.65405",
|
|
9
|
+
"Mozilla/5.0 (Windows; U; Windows NT 10.4; x64) AppleWebKit/536.41 (KHTML, like Gecko) Chrome/53.0.3535.112 Safari/600.5 Edge/14.39786",
|
|
10
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_0; like Mac OS X) AppleWebKit/601.9 (KHTML, like Gecko) Chrome/47.0.2876.394 Mobile Safari/600.5",
|
|
11
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 7_6_3; like Mac OS X) AppleWebKit/602.24 (KHTML, like Gecko) Chrome/54.0.3204.297 Mobile Safari/537.0",
|
|
12
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_9_6; like Mac OS X) AppleWebKit/601.4 (KHTML, like Gecko) Chrome/55.0.2808.105 Mobile Safari/600.4",
|
|
13
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 8_2_1; like Mac OS X) AppleWebKit/600.14 (KHTML, like Gecko) Chrome/50.0.3808.259 Mobile Safari/534.1",
|
|
14
|
+
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_4_2; like Mac OS X) AppleWebKit/534.21 (KHTML, like Gecko) Chrome/47.0.3531.351 Mobile Safari/533.0"
|
|
15
|
+
];
|
|
16
|
+
const DEFAULT_HEADERS = {
|
|
17
|
+
"User-Agent": USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],
|
|
18
|
+
"Cache-Control": "no-cache"
|
|
19
|
+
};
|
|
20
|
+
/** Plain `fetch`, for React Native and browsers where got-scraping cannot run. */
|
|
21
|
+
const fetchPage = async (url, headersCustom) => {
|
|
22
|
+
try {
|
|
23
|
+
const response = await fetch(url, {
|
|
24
|
+
headers: {
|
|
25
|
+
...DEFAULT_HEADERS,
|
|
26
|
+
...headersCustom
|
|
27
|
+
},
|
|
28
|
+
credentials: "omit"
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) throw new Error(`atlas-obscura-api: Bad response ${response.status} for url: ${url}`);
|
|
31
|
+
return await response.text();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error("fetchPage error:", error);
|
|
34
|
+
return "Error";
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
// src/index.fetch.ts
|
|
38
|
+
const atlasObscura = new AtlasObscura(new PlacesScraper(fetchPage));
|
|
39
|
+
export { AtlasObscura, atlasObscura };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=index.fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.fetch.js","names":[],"sources":["../src/fetchers/fetch.ts","../src/index.fetch.ts"],"sourcesContent":["import { FetchPage } from './types.js';\n\nconst USER_AGENTS: string[] = [\n 'Dalvik/2.1.0 (Linux; U; Android 8.1.0; C6L Build/OPM2.171019.012)',\n 'Mozilla/5.0 (Windows; Windows NT 10.0; x64) AppleWebKit/537.50 (KHTML, like Gecko) Chrome/48.0.2572.385 Safari/537.9 Edge/8.37913',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14E5239e Safari/602.1',\n 'Dalvik/2.1.0 (Linux; U; Android 11; SM-A505GT Build/RP1A.200720.012)',\n 'Mozilla/5.0 (Windows NT 10.3;; en-US) AppleWebKit/602.25 (KHTML, like Gecko) Chrome/54.0.2457.241 Safari/534.5 Edge/9.65405',\n 'Mozilla/5.0 (Windows; U; Windows NT 10.4; x64) AppleWebKit/536.41 (KHTML, like Gecko) Chrome/53.0.3535.112 Safari/600.5 Edge/14.39786',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_0; like Mac OS X) AppleWebKit/601.9 (KHTML, like Gecko) Chrome/47.0.2876.394 Mobile Safari/600.5',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_6_3; like Mac OS X) AppleWebKit/602.24 (KHTML, like Gecko) Chrome/54.0.3204.297 Mobile Safari/537.0',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_9_6; like Mac OS X) AppleWebKit/601.4 (KHTML, like Gecko) Chrome/55.0.2808.105 Mobile Safari/600.4',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_2_1; like Mac OS X) AppleWebKit/600.14 (KHTML, like Gecko) Chrome/50.0.3808.259 Mobile Safari/534.1',\n 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_4_2; like Mac OS X) AppleWebKit/534.21 (KHTML, like Gecko) Chrome/47.0.3531.351 Mobile Safari/533.0'\n];\n\nconst DEFAULT_HEADERS: Record<string, string> = {\n 'User-Agent': USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],\n 'Cache-Control': 'no-cache'\n};\n\n/** Plain `fetch`, for React Native and browsers where got-scraping cannot run. */\nexport const fetchPage: FetchPage = async (url, headersCustom) => {\n try {\n const response = await fetch(url, {\n headers: { ...DEFAULT_HEADERS, ...headersCustom },\n credentials: 'omit'\n });\n\n if (!response.ok) {\n throw new Error(`atlas-obscura-api: Bad response ${response.status} for url: ${url}`);\n }\n\n return await response.text();\n } catch (error) {\n console.error('fetchPage error:', error);\n return 'Error';\n }\n};\n","// Entry for React Native and browsers (see \"exports\" in package.json); same API, but no got-scraping.\nimport { AtlasObscura } from './atlas-obscura.js';\nimport { fetchPage } from './fetchers/fetch.js';\nimport { PlacesScraper } from './services/location.service.js';\n\nexport { AtlasObscura } from './atlas-obscura.js';\nexport const atlasObscura: AtlasObscura = new AtlasObscura(new PlacesScraper(fetchPage));\nexport type * from './interfaces/index.js';\n"],"mappings":";;AAEA,MAAM,cAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,kBAA0C;CAC9C,cAAc,YAAY,KAAK,MAAM,KAAK,OAAO,IAAI,YAAY,MAAM;CACvE,iBAAiB;AACnB;;AAGA,MAAa,YAAuB,OAAO,KAAK,kBAAkB;CAChE,IAAI;EACF,MAAM,WAAW,MAAM,MAAM,KAAK;GAChC,SAAS;IAAE,GAAG;IAAiB,GAAG;GAAc;GAChD,aAAa;EACf,CAAC;EAED,IAAI,CAAC,SAAS,IACZ,MAAM,IAAI,MAAM,mCAAmC,SAAS,OAAO,YAAY,KAAK;EAGtF,OAAO,MAAM,SAAS,KAAK;CAC7B,SAAS,OAAO;EACd,QAAQ,MAAM,oBAAoB,KAAK;EACvC,OAAO;CACT;AACF;;AChCA,MAAa,eAA6B,IAAI,aAAa,IAAI,cAAc,SAAS,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as AtlasObscura, t as PlacesScraper } from "./location.service-CR5JY1Ij.js";
|
|
2
2
|
import { gotScraping } from "got-scraping";
|
|
3
|
-
|
|
3
|
+
// src/fetchers/got.ts
|
|
4
4
|
const fetchPage = async (url, headersCustom) => {
|
|
5
5
|
try {
|
|
6
6
|
return (await gotScraping({
|
|
@@ -24,109 +24,14 @@ const fetchPage = async (url, headersCustom) => {
|
|
|
24
24
|
http2: true
|
|
25
25
|
})).body;
|
|
26
26
|
} catch (error) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const statusCode = error.response?.statusCode;
|
|
28
|
+
if (statusCode) console.error(`atlas-obscura-api: Request failed with status code ${statusCode} for url: ${url}`);
|
|
29
|
+
else console.error("fetchPage error:", error instanceof Error ? error.message : error);
|
|
29
30
|
return "Error";
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const parseResults = (matches) => {
|
|
35
|
-
let locations = null;
|
|
36
|
-
if (matches && matches[1]?.length) try {
|
|
37
|
-
locations = JSON.parse(matches[1]);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error("Error parsing all places");
|
|
40
|
-
}
|
|
41
|
-
return locations;
|
|
42
|
-
};
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/vars.ts
|
|
45
|
-
const URL_PLACES_ALL = "https://www.atlasobscura.com/articles/all-places-in-the-atlas-on-one-map";
|
|
46
|
-
const urlSearch = (coord, page) => `https://www.atlasobscura.com/search?utf8=%E2%9C%93&q=&location=&nearby=true&lat=${coord.lat}&lng=${coord.lng}${page ? "&page=" + page : ""}`;
|
|
47
|
-
const urlPlaceId = (id) => `https://www.atlasobscura.com/places/${id}.json?place_only=1`;
|
|
48
|
-
const urlUser = (name) => `https://www.atlasobscura.com/users/${name}`;
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/services/location.service.ts
|
|
51
|
-
var PlacesScraper = class {
|
|
52
|
-
async placesAll(options) {
|
|
53
|
-
return parseResults(parse(await fetchPage(URL_PLACES_ALL, options?.headers)).innerHTML.match(/AtlasObscura\.all_places = (.*?);/));
|
|
54
|
-
}
|
|
55
|
-
async search(coords, page = 1, options) {
|
|
56
|
-
return parseResults(parse(await fetchPage(urlSearch(coords, page), options?.headers)).innerHTML.match(/AtlasObscura\.place_search = (.*?);/));
|
|
57
|
-
}
|
|
58
|
-
async placeByIdShort(id, options) {
|
|
59
|
-
const data = await fetchPage(urlPlaceId(id), options?.headers);
|
|
60
|
-
let place = null;
|
|
61
|
-
try {
|
|
62
|
-
place = JSON.parse(data);
|
|
63
|
-
if (place && typeof place.hide_from_maps === "string") place.hide_from_maps = place.hide_from_maps === "true";
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error("Error parsing placeById", id);
|
|
66
|
-
}
|
|
67
|
-
return place;
|
|
68
|
-
}
|
|
69
|
-
async placeFull(url, options) {
|
|
70
|
-
const html = parse(await fetchPage(url, options?.headers));
|
|
71
|
-
const descriptions = html.querySelectorAll(".place-body p").map((p) => p.innerHTML);
|
|
72
|
-
const sectionDirections = Array.from(html.querySelectorAll("section")).find((sec) => {
|
|
73
|
-
const h2 = sec.querySelector("h2");
|
|
74
|
-
return h2 && h2.textContent.trim() === "Know Before You Go";
|
|
75
|
-
});
|
|
76
|
-
const directions = sectionDirections ? Array.from(sectionDirections.querySelectorAll("p")).map((p) => p.textContent.trim()) : [];
|
|
77
|
-
const tags = html.querySelectorAll(".aon-pill-badge-component").map((x) => {
|
|
78
|
-
return {
|
|
79
|
-
title: x.querySelector(".aon-pill-badge-text")?.innerHTML.trim(),
|
|
80
|
-
link: x.attributes.href
|
|
81
|
-
};
|
|
82
|
-
});
|
|
83
|
-
const slides = html.querySelectorAll(".swiper-slide");
|
|
84
|
-
const images = Array.from(slides).map((slide) => {
|
|
85
|
-
const img = slide.querySelector("img");
|
|
86
|
-
return img ? img.getAttribute("src") : null;
|
|
87
|
-
}).filter(Boolean);
|
|
88
|
-
return {
|
|
89
|
-
description: descriptions,
|
|
90
|
-
directions,
|
|
91
|
-
tags,
|
|
92
|
-
imageCover: images[0],
|
|
93
|
-
images
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
async user(user, options) {
|
|
97
|
-
return parseResults(parse(await fetchPage(urlUser(user), options?.headers)).innerHTML.match(/AtlasObscura\.user_profile = (.*?);/)).user;
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region src/index.ts
|
|
102
|
-
var AtlasObscura = class {
|
|
103
|
-
locationService;
|
|
104
|
-
constructor(locationService) {
|
|
105
|
-
this.locationService = locationService;
|
|
106
|
-
}
|
|
107
|
-
async search(coords, options) {
|
|
108
|
-
return this.locationService.search(coords, 1, options);
|
|
109
|
-
}
|
|
110
|
-
async placesAll(options) {
|
|
111
|
-
return this.locationService.placesAll(options);
|
|
112
|
-
}
|
|
113
|
-
async placeShort(id, options) {
|
|
114
|
-
return this.locationService.placeByIdShort(id, options);
|
|
115
|
-
}
|
|
116
|
-
async placeFull(id, options) {
|
|
117
|
-
const place = await this.locationService.placeByIdShort(id, options);
|
|
118
|
-
const placeRich = await this.locationService.placeFull(place.url, options);
|
|
119
|
-
return {
|
|
120
|
-
...place,
|
|
121
|
-
...placeRich
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
async user(user, options) {
|
|
125
|
-
return this.locationService.user(user, options);
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
const atlasObscura = new AtlasObscura(new PlacesScraper());
|
|
129
|
-
//#endregion
|
|
33
|
+
// src/index.ts
|
|
34
|
+
const atlasObscura = new AtlasObscura(new PlacesScraper(fetchPage));
|
|
130
35
|
export { AtlasObscura, atlasObscura };
|
|
131
36
|
|
|
132
37
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/fetchers/index.ts","../src/utils.ts","../src/vars.ts","../src/services/location.service.ts","../src/index.ts"],"sourcesContent":["import { gotScraping } from 'got-scraping';\n\nexport const fetchPage = async (url: string, headersCustom?: Record<string, string>): Promise<string> => {\n try {\n const response = await gotScraping({\n url,\n // Configuration to mimic a modern desktop browser (Chrome/Firefox)\n headerGeneratorOptions: {\n browsers: [\n { name: 'chrome', minVersion: 115 },\n { name: 'firefox', minVersion: 115 }\n ],\n devices: ['desktop'],\n locales: ['en-US'],\n operatingSystems: ['windows', 'macos'],\n },\n headers: {\n 'Cache-Control': 'no-cache',\n ...headersCustom,\n },\n // Optional: HTTP2 is often faster and less suspicious for modern sites,\n // but sometimes causes stability issues. Try true if false doesn't work.\n http2: true,\n });\n\n return response.body;\n\n } catch (error: any) {\n // Better error logging to debug 403s\n if (error.response) {\n console.error(`atlas-obscura-api: Request failed with status code ${error.response.statusCode} for url: ${url}`);\n } else {\n console.error('fetchPage error:', error.message);\n }\n\n return 'Error';\n }\n};","export const parseResults = <T>(matches: RegExpMatchArray): T => {\n let locations: T = null;\n\n if (matches && matches[1]?.length) {\n try {\n locations = JSON.parse(matches[1]);\n } catch (error) {\n console.error('Error parsing all places');\n }\n }\n return locations;\n};\n","export const URL_PLACES_ALL =\n 'https://www.atlasobscura.com/articles/all-places-in-the-atlas-on-one-map';\n\nexport const urlSearch = (coord: { lat: number; lng: number }, page?: number): string =>\n `https://www.atlasobscura.com/search?utf8=%E2%9C%93&q=&location=&nearby=true&lat=${coord.lat\n }&lng=${coord.lng}${page ? '&page=' + page : ''}`;\n\nexport const urlPlaceId = (id: number): string =>\n `https://www.atlasobscura.com/places/${id}.json?place_only=1`;\n\nexport const urlUser = (name: string): string =>\n `https://www.atlasobscura.com/users/${name}`;\n","import { parse } from 'node-html-parser';\nimport { fetchPage } from '../fetchers/index.js';\nimport { AOUser } from '../interfaces/user.interface.js';\nimport { parseResults } from '../utils.js';\nimport { URL_PLACES_ALL, urlPlaceId, urlSearch, urlUser } from '../vars.js';\nimport { AOCoordinates, AOFetchOptions } from './../interfaces/global.js';\nimport { AOLocationResult } from './../interfaces/locations.interface.js';\nimport { AOPlaceExtend, AOPlaceShort } from './../interfaces/placeId.interface.js';\nimport { AOPlacesAll } from './../interfaces/places-all.interface.js';\n\nexport class PlacesScraper {\n public async placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]> {\n const response = await fetchPage(URL_PLACES_ALL, options?.headers);\n const html = parse(response).innerHTML;\n\n const data = html.match(/AtlasObscura\\.all_places = (.*?);/);\n\n return parseResults<AOPlacesAll[]>(data);\n }\n\n public async search(coords: AOCoordinates, page = 1, options?: AOFetchOptions): Promise<AOLocationResult> {\n const url = urlSearch(coords, page);\n const response = await fetchPage(url, options?.headers);\n const html = parse(response).innerHTML;\n\n const data = html.match(/AtlasObscura\\.place_search = (.*?);/);\n\n return parseResults<AOLocationResult>(data);\n }\n\n public async placeByIdShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort> {\n const url = urlPlaceId(id);\n const data = await fetchPage(url, options?.headers);\n\n let place: AOPlaceShort = null;\n\n try {\n place = JSON.parse(data);\n if (place && typeof place.hide_from_maps === 'string') {\n (place as any).hide_from_maps = place.hide_from_maps === 'true';\n }\n } catch (error) {\n console.error('Error parsing placeById', id);\n }\n return place;\n }\n\n public async placeFull(url: string, options?: AOFetchOptions): Promise<AOPlaceExtend> {\n const data = await fetchPage(url, options?.headers);\n const html = parse(data);\n\n const descriptions = html.querySelectorAll('.place-body p').map((p) => p.innerHTML);\n\n const sectionDirections = Array.from(html.querySelectorAll('section')).find((sec) => {\n const h2 = sec.querySelector('h2');\n return h2 && h2.textContent.trim() === 'Know Before You Go';\n });\n const directions = sectionDirections\n ? Array.from(sectionDirections.querySelectorAll('p')).map((p) => p.textContent.trim())\n : [];\n\n const tags = html.querySelectorAll('.aon-pill-badge-component').map((x) => {\n return {\n title: x.querySelector('.aon-pill-badge-text')?.innerHTML.trim(),\n link: x.attributes.href\n };\n });\n\n const slides = html.querySelectorAll('.swiper-slide');\n const images = Array.from(slides)\n .map((slide) => {\n const img = slide.querySelector('img');\n return img ? img.getAttribute('src') : null;\n })\n .filter(Boolean);\n\n const imageCover = images[0];\n\n return { description: descriptions, directions, tags, imageCover, images };\n }\n\n public async user(user: string, options?: AOFetchOptions): Promise<AOUser> {\n const url = urlUser(user);\n const response = await fetchPage(url, options?.headers);\n const html = parse(response).innerHTML;\n\n const data = html.match(/AtlasObscura\\.user_profile = (.*?);/);\n\n const usr = parseResults<{ user: AOUser }>(data);\n\n return usr.user;\n }\n}\n","import { AOCoordinates, AOFetchOptions } from './interfaces/global.js';\nimport { AOLocationResult } from './interfaces/locations.interface.js';\nimport { AOPlace, AOPlaceShort } from './interfaces/placeId.interface.js';\nimport { AOPlacesAll } from './interfaces/places-all.interface.js';\nimport { AOUser } from './interfaces/user.interface.js';\nimport { PlacesScraper } from './services/location.service.js';\n\nexport class AtlasObscura {\n constructor(private locationService: PlacesScraper) { }\n\n public async search(coords: AOCoordinates, options?: AOFetchOptions): Promise<AOLocationResult> {\n return this.locationService.search(coords, 1, options);\n }\n\n public async placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]> {\n return this.locationService.placesAll(options);\n }\n\n public async placeShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort> {\n return this.locationService.placeByIdShort(id, options);\n }\n\n public async placeFull(id: number, options?: AOFetchOptions): Promise<AOPlace> {\n const place = await this.locationService.placeByIdShort(id, options);\n const placeRich = await this.locationService.placeFull(place.url, options);\n return { ...place, ...placeRich };\n }\n\n public async user(user: string, options?: AOFetchOptions): Promise<AOUser> {\n return this.locationService.user(user, options);\n }\n}\n\nconst locationScraper = new PlacesScraper();\nexport const atlasObscura: AtlasObscura = new AtlasObscura(locationScraper);\nexport type * from './interfaces/index.js';\n"],"mappings":";;;AAEA,MAAa,YAAY,OAAO,KAAa,kBAA4D;CACvG,IAAI;EAsBF,QAAO,MArBgB,YAAY;GACjC;GAEA,wBAAwB;IACtB,UAAU,CACR;KAAE,MAAM;KAAU,YAAY;IAAI,GAClC;KAAE,MAAM;KAAW,YAAY;IAAI,CACrC;IACA,SAAS,CAAC,SAAS;IACnB,SAAS,CAAC,OAAO;IACjB,kBAAkB,CAAC,WAAW,OAAO;GACvC;GACA,SAAS;IACP,iBAAiB;IACjB,GAAG;GACL;GAGA,OAAO;EACT,CAAC,GAEe;CAElB,SAAS,OAAY;EAEnB,IAAI,MAAM,UACR,QAAQ,MAAM,sDAAsD,MAAM,SAAS,WAAW,YAAY,KAAK;OAE/G,QAAQ,MAAM,oBAAoB,MAAM,OAAO;EAGjD,OAAO;CACT;AACF;;;ACrCA,MAAa,gBAAmB,YAAiC;CAC/D,IAAI,YAAe;CAEnB,IAAI,WAAW,QAAQ,IAAI,QACzB,IAAI;EACF,YAAY,KAAK,MAAM,QAAQ,EAAE;CACnC,SAAS,OAAO;EACd,QAAQ,MAAM,0BAA0B;CAC1C;CAEF,OAAO;AACT;;;ACXA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A6B,IAAI,aAAa,IAD/B,cAC+B,CAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/fetchers/got.ts","../src/index.ts"],"sourcesContent":["import { gotScraping } from 'got-scraping';\nimport { FetchPage } from './types.js';\n\nexport const fetchPage: FetchPage = async (url, headersCustom) => {\n try {\n const response = await gotScraping({\n url,\n // Configuration to mimic a modern desktop browser (Chrome/Firefox)\n headerGeneratorOptions: {\n browsers: [\n { name: 'chrome', minVersion: 115 },\n { name: 'firefox', minVersion: 115 }\n ],\n devices: ['desktop'],\n locales: ['en-US'],\n operatingSystems: ['windows', 'macos']\n },\n headers: {\n 'Cache-Control': 'no-cache',\n ...headersCustom\n },\n // Optional: HTTP2 is often faster and less suspicious for modern sites,\n // but sometimes causes stability issues. Try true if false doesn't work.\n http2: true\n });\n\n return response.body;\n } catch (error) {\n // Better error logging to debug 403s\n const statusCode = (error as { response?: { statusCode?: number } }).response?.statusCode;\n if (statusCode) {\n console.error(\n `atlas-obscura-api: Request failed with status code ${statusCode} for url: ${url}`\n );\n } else {\n console.error('fetchPage error:', error instanceof Error ? error.message : error);\n }\n\n return 'Error';\n }\n};\n","import { AtlasObscura } from './atlas-obscura.js';\nimport { fetchPage } from './fetchers/got.js';\nimport { PlacesScraper } from './services/location.service.js';\n\nexport { AtlasObscura } from './atlas-obscura.js';\nexport const atlasObscura: AtlasObscura = new AtlasObscura(new PlacesScraper(fetchPage));\nexport type * from './interfaces/index.js';\n"],"mappings":";;;AAGA,MAAa,YAAuB,OAAO,KAAK,kBAAkB;CAChE,IAAI;EAsBF,QAAO,MArBgB,YAAY;GACjC;GAEA,wBAAwB;IACtB,UAAU,CACR;KAAE,MAAM;KAAU,YAAY;IAAI,GAClC;KAAE,MAAM;KAAW,YAAY;IAAI,CACrC;IACA,SAAS,CAAC,SAAS;IACnB,SAAS,CAAC,OAAO;IACjB,kBAAkB,CAAC,WAAW,OAAO;GACvC;GACA,SAAS;IACP,iBAAiB;IACjB,GAAG;GACL;GAGA,OAAO;EACT,CAAC,EAAA,CAEe;CAClB,SAAS,OAAO;EAEd,MAAM,aAAc,MAAiD,UAAU;EAC/E,IAAI,YACF,QAAQ,MACN,sDAAsD,WAAW,YAAY,KAC/E;OAEA,QAAQ,MAAM,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,KAAK;EAGlF,OAAO;CACT;AACF;;ACnCA,MAAa,eAA6B,IAAI,aAAa,IAAI,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { parse } from "node-html-parser";
|
|
2
|
+
// src/atlas-obscura.ts
|
|
3
|
+
var AtlasObscura = class {
|
|
4
|
+
locationService;
|
|
5
|
+
constructor(locationService) {
|
|
6
|
+
this.locationService = locationService;
|
|
7
|
+
}
|
|
8
|
+
async search(coords, options) {
|
|
9
|
+
return this.locationService.search(coords, 1, options);
|
|
10
|
+
}
|
|
11
|
+
async placesAll(options) {
|
|
12
|
+
return this.locationService.placesAll(options);
|
|
13
|
+
}
|
|
14
|
+
async placeShort(id, options) {
|
|
15
|
+
return this.locationService.placeByIdShort(id, options);
|
|
16
|
+
}
|
|
17
|
+
async placeFull(id, options) {
|
|
18
|
+
const place = await this.locationService.placeByIdShort(id, options);
|
|
19
|
+
const placeRich = await this.locationService.placeFull(place.url, options);
|
|
20
|
+
return {
|
|
21
|
+
...place,
|
|
22
|
+
...placeRich
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async user(user, options) {
|
|
26
|
+
return this.locationService.user(user, options);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// src/utils.ts
|
|
30
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
31
|
+
/**
|
|
32
|
+
* The map endpoint returns compact `[id, lat, lng]` tuples. The old page embedded
|
|
33
|
+
* `{ id, lat, lng }` objects, so both are accepted.
|
|
34
|
+
*/
|
|
35
|
+
const parsePlacesAll = (body) => {
|
|
36
|
+
let data;
|
|
37
|
+
try {
|
|
38
|
+
data = JSON.parse(body);
|
|
39
|
+
} catch {
|
|
40
|
+
console.error("Error parsing all places");
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(data)) return null;
|
|
44
|
+
return data.map((item) => {
|
|
45
|
+
if (Array.isArray(item)) {
|
|
46
|
+
const [id, lat, lng] = item;
|
|
47
|
+
return {
|
|
48
|
+
id,
|
|
49
|
+
lat,
|
|
50
|
+
lng
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return item;
|
|
54
|
+
}).filter((place) => !!place && isFiniteNumber(place.id) && isFiniteNumber(place.lat) && isFiniteNumber(place.lng));
|
|
55
|
+
};
|
|
56
|
+
const parseResults = (matches) => {
|
|
57
|
+
let locations = null;
|
|
58
|
+
if (matches && matches[1]?.length) try {
|
|
59
|
+
locations = JSON.parse(matches[1]);
|
|
60
|
+
} catch {
|
|
61
|
+
console.error("Error parsing all places");
|
|
62
|
+
}
|
|
63
|
+
return locations;
|
|
64
|
+
};
|
|
65
|
+
// src/vars.ts
|
|
66
|
+
const URL_PLACES_ALL = "https://www.atlasobscura.com/aon/map/places/all";
|
|
67
|
+
const urlSearch = (coord, page) => `https://www.atlasobscura.com/search?utf8=%E2%9C%93&q=&location=&nearby=true&lat=${coord.lat}&lng=${coord.lng}${page ? "&page=" + page : ""}`;
|
|
68
|
+
const urlPlaceId = (id) => `https://www.atlasobscura.com/places/${id}.json?place_only=1`;
|
|
69
|
+
const urlUser = (name) => `https://www.atlasobscura.com/users/${name}`;
|
|
70
|
+
// src/services/location.service.ts
|
|
71
|
+
var PlacesScraper = class {
|
|
72
|
+
fetchPage;
|
|
73
|
+
constructor(fetchPage) {
|
|
74
|
+
this.fetchPage = fetchPage;
|
|
75
|
+
}
|
|
76
|
+
async placesAll(options) {
|
|
77
|
+
const response = await this.fetchPage(URL_PLACES_ALL, options?.headers);
|
|
78
|
+
return parsePlacesAll(response);
|
|
79
|
+
}
|
|
80
|
+
async search(coords, page = 1, options) {
|
|
81
|
+
const url = urlSearch(coords, page);
|
|
82
|
+
const response = await this.fetchPage(url, options?.headers);
|
|
83
|
+
const data = parse(response).innerHTML.match(/AtlasObscura\.place_search = (.*?);/);
|
|
84
|
+
return parseResults(data);
|
|
85
|
+
}
|
|
86
|
+
async placeByIdShort(id, options) {
|
|
87
|
+
const url = urlPlaceId(id);
|
|
88
|
+
const data = await this.fetchPage(url, options?.headers);
|
|
89
|
+
let place = null;
|
|
90
|
+
try {
|
|
91
|
+
const raw = JSON.parse(data);
|
|
92
|
+
place = raw && typeof raw.hide_from_maps === "string" ? {
|
|
93
|
+
...raw,
|
|
94
|
+
hide_from_maps: raw.hide_from_maps === "true"
|
|
95
|
+
} : raw;
|
|
96
|
+
} catch {
|
|
97
|
+
console.error("Error parsing placeById", id);
|
|
98
|
+
}
|
|
99
|
+
return place;
|
|
100
|
+
}
|
|
101
|
+
async placeFull(url, options) {
|
|
102
|
+
const data = await this.fetchPage(url, options?.headers);
|
|
103
|
+
const html = parse(data);
|
|
104
|
+
const descriptions = html.querySelectorAll(".place-body p").map((p) => p.innerHTML);
|
|
105
|
+
const sectionDirections = Array.from(html.querySelectorAll("section")).find((sec) => {
|
|
106
|
+
const h2 = sec.querySelector("h2");
|
|
107
|
+
return h2 && h2.textContent.trim() === "Know Before You Go";
|
|
108
|
+
});
|
|
109
|
+
const directions = sectionDirections ? Array.from(sectionDirections.querySelectorAll("p")).map((p) => p.textContent.trim()) : [];
|
|
110
|
+
const tags = html.querySelectorAll(".aon-pill-badge-component").map((x) => {
|
|
111
|
+
return {
|
|
112
|
+
title: x.querySelector(".aon-pill-badge-text")?.innerHTML.trim(),
|
|
113
|
+
link: x.attributes.href
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
const slides = html.querySelectorAll(".swiper-slide");
|
|
117
|
+
const images = Array.from(slides).map((slide) => {
|
|
118
|
+
const img = slide.querySelector("img");
|
|
119
|
+
return img ? img.getAttribute("src") : null;
|
|
120
|
+
}).filter(Boolean);
|
|
121
|
+
return {
|
|
122
|
+
description: descriptions,
|
|
123
|
+
directions,
|
|
124
|
+
tags,
|
|
125
|
+
imageCover: images[0],
|
|
126
|
+
images
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
async user(user, options) {
|
|
130
|
+
const url = urlUser(user);
|
|
131
|
+
const response = await this.fetchPage(url, options?.headers);
|
|
132
|
+
const data = parse(response).innerHTML.match(/AtlasObscura\.user_profile = (.*?);/);
|
|
133
|
+
return parseResults(data).user;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
export { AtlasObscura as n, PlacesScraper as t };
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=location.service-CR5JY1Ij.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.service-CR5JY1Ij.js","names":[],"sources":["../src/atlas-obscura.ts","../src/utils.ts","../src/vars.ts","../src/services/location.service.ts"],"sourcesContent":["import { AOCoordinates, AOFetchOptions } from './interfaces/global.js';\nimport { AOLocationResult } from './interfaces/locations.interface.js';\nimport { AOPlace, AOPlaceShort } from './interfaces/placeId.interface.js';\nimport { AOPlacesAll } from './interfaces/places-all.interface.js';\nimport { AOUser } from './interfaces/user.interface.js';\nimport { PlacesScraper } from './services/location.service.js';\n\nexport class AtlasObscura {\n constructor(private locationService: PlacesScraper) {}\n\n public async search(coords: AOCoordinates, options?: AOFetchOptions): Promise<AOLocationResult> {\n return this.locationService.search(coords, 1, options);\n }\n\n public async placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]> {\n return this.locationService.placesAll(options);\n }\n\n public async placeShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort> {\n return this.locationService.placeByIdShort(id, options);\n }\n\n public async placeFull(id: number, options?: AOFetchOptions): Promise<AOPlace> {\n const place = await this.locationService.placeByIdShort(id, options);\n const placeRich = await this.locationService.placeFull(place.url, options);\n return { ...place, ...placeRich };\n }\n\n public async user(user: string, options?: AOFetchOptions): Promise<AOUser> {\n return this.locationService.user(user, options);\n }\n}\n","import { AOPlacesAll } from './interfaces/places-all.interface.js';\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === 'number' && Number.isFinite(value);\n\n/**\n * The map endpoint returns compact `[id, lat, lng]` tuples. The old page embedded\n * `{ id, lat, lng }` objects, so both are accepted.\n */\nexport const parsePlacesAll = (body: string): AOPlacesAll[] => {\n let data: unknown;\n\n try {\n data = JSON.parse(body);\n } catch {\n console.error('Error parsing all places');\n return null;\n }\n\n if (!Array.isArray(data)) {\n return null;\n }\n\n return data\n .map((item): AOPlacesAll => {\n if (Array.isArray(item)) {\n const [id, lat, lng] = item;\n return { id, lat, lng };\n }\n return item;\n })\n .filter(\n (place) =>\n !!place &&\n isFiniteNumber(place.id) &&\n isFiniteNumber(place.lat) &&\n isFiniteNumber(place.lng)\n );\n};\n\nexport const parseResults = <T>(matches: RegExpMatchArray): T => {\n let locations: T = null;\n\n if (matches && matches[1]?.length) {\n try {\n locations = JSON.parse(matches[1]);\n } catch {\n console.error('Error parsing all places');\n }\n }\n return locations;\n};\n","export const URL_PLACES_ALL = 'https://www.atlasobscura.com/aon/map/places/all';\n\nexport const urlSearch = (coord: { lat: number; lng: number }, page?: number): string =>\n `https://www.atlasobscura.com/search?utf8=%E2%9C%93&q=&location=&nearby=true&lat=${\n coord.lat\n }&lng=${coord.lng}${page ? '&page=' + page : ''}`;\n\nexport const urlPlaceId = (id: number): string =>\n `https://www.atlasobscura.com/places/${id}.json?place_only=1`;\n\nexport const urlUser = (name: string): string => `https://www.atlasobscura.com/users/${name}`;\n","import { parse } from 'node-html-parser';\nimport { FetchPage } from '../fetchers/types.js';\nimport { AOUser } from '../interfaces/user.interface.js';\nimport { parsePlacesAll, parseResults } from '../utils.js';\nimport { URL_PLACES_ALL, urlPlaceId, urlSearch, urlUser } from '../vars.js';\nimport { AOCoordinates, AOFetchOptions } from './../interfaces/global.js';\nimport { AOLocationResult } from './../interfaces/locations.interface.js';\nimport { AOPlaceExtend, AOPlaceShort } from './../interfaces/placeId.interface.js';\nimport { AOPlacesAll } from './../interfaces/places-all.interface.js';\n\nexport class PlacesScraper {\n constructor(private readonly fetchPage: FetchPage) {}\n\n public async placesAll(options?: AOFetchOptions): Promise<AOPlacesAll[]> {\n const response = await this.fetchPage(URL_PLACES_ALL, options?.headers);\n return parsePlacesAll(response);\n }\n\n public async search(\n coords: AOCoordinates,\n page = 1,\n options?: AOFetchOptions\n ): Promise<AOLocationResult> {\n const url = urlSearch(coords, page);\n const response = await this.fetchPage(url, options?.headers);\n const html = parse(response).innerHTML;\n\n const data = html.match(/AtlasObscura\\.place_search = (.*?);/);\n\n return parseResults<AOLocationResult>(data);\n }\n\n public async placeByIdShort(id: number, options?: AOFetchOptions): Promise<AOPlaceShort> {\n const url = urlPlaceId(id);\n const data = await this.fetchPage(url, options?.headers);\n\n let place: AOPlaceShort = null;\n\n try {\n // The JSON endpoint sends hide_from_maps as \"true\"/\"false\"\n const raw: Omit<AOPlaceShort, 'hide_from_maps'> & { hide_from_maps?: string | boolean } =\n JSON.parse(data);\n place =\n raw && typeof raw.hide_from_maps === 'string'\n ? { ...raw, hide_from_maps: raw.hide_from_maps === 'true' }\n : (raw as AOPlaceShort);\n } catch {\n console.error('Error parsing placeById', id);\n }\n return place;\n }\n\n public async placeFull(url: string, options?: AOFetchOptions): Promise<AOPlaceExtend> {\n const data = await this.fetchPage(url, options?.headers);\n const html = parse(data);\n\n const descriptions = html.querySelectorAll('.place-body p').map((p) => p.innerHTML);\n\n const sectionDirections = Array.from(html.querySelectorAll('section')).find((sec) => {\n const h2 = sec.querySelector('h2');\n return h2 && h2.textContent.trim() === 'Know Before You Go';\n });\n const directions = sectionDirections\n ? Array.from(sectionDirections.querySelectorAll('p')).map((p) => p.textContent.trim())\n : [];\n\n const tags = html.querySelectorAll('.aon-pill-badge-component').map((x) => {\n return {\n title: x.querySelector('.aon-pill-badge-text')?.innerHTML.trim(),\n link: x.attributes.href\n };\n });\n\n const slides = html.querySelectorAll('.swiper-slide');\n const images = Array.from(slides)\n .map((slide) => {\n const img = slide.querySelector('img');\n return img ? img.getAttribute('src') : null;\n })\n .filter(Boolean);\n\n const imageCover = images[0];\n\n return { description: descriptions, directions, tags, imageCover, images };\n }\n\n public async user(user: string, options?: AOFetchOptions): Promise<AOUser> {\n const url = urlUser(user);\n const response = await this.fetchPage(url, options?.headers);\n const html = parse(response).innerHTML;\n\n const data = html.match(/AtlasObscura\\.user_profile = (.*?);/);\n\n const usr = parseResults<{ user: AOUser }>(data);\n\n return usr.user;\n }\n}\n"],"mappings":";;AAOA,IAAa,eAAb,MAA0B;CACJ;CAApB,YAAoB,iBAAgC;EAAhC,KAAA,kBAAA;CAAiC;CAErD,MAAa,OAAO,QAAuB,SAAqD;EAC9F,OAAO,KAAK,gBAAgB,OAAO,QAAQ,GAAG,OAAO;CACvD;CAEA,MAAa,UAAU,SAAkD;EACvE,OAAO,KAAK,gBAAgB,UAAU,OAAO;CAC/C;CAEA,MAAa,WAAW,IAAY,SAAiD;EACnF,OAAO,KAAK,gBAAgB,eAAe,IAAI,OAAO;CACxD;CAEA,MAAa,UAAU,IAAY,SAA4C;EAC7E,MAAM,QAAQ,MAAM,KAAK,gBAAgB,eAAe,IAAI,OAAO;EACnE,MAAM,YAAY,MAAM,KAAK,gBAAgB,UAAU,MAAM,KAAK,OAAO;EACzE,OAAO;GAAE,GAAG;GAAO,GAAG;EAAU;CAClC;CAEA,MAAa,KAAK,MAAc,SAA2C;EACzE,OAAO,KAAK,gBAAgB,KAAK,MAAM,OAAO;CAChD;AACF;;AC7BA,MAAM,kBAAkB,UACtB,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK;;;;;AAMpD,MAAa,kBAAkB,SAAgC;CAC7D,IAAI;CAEJ,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,QAAQ;EACN,QAAQ,MAAM,0BAA0B;EACxC,OAAO;CACT;CAEA,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,OAAO;CA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AM,WAAW,MAAM,KAAK,UAAU,KAAK,SAAS,OAAO;EAG3D,MAAM,OAFO,MAAM,QAAQ,CAAC,CAAC,UAEX,MAAM,qCAAqC;EAI7D,OAFY,aAA+B,IAElC,CAAC,CAAC;CACb;AACF"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atlas-obscura-api",
|
|
3
|
-
"version": "5.1
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Atlas Obscura API in JavaScript. NPM library for scrapping atlasobscura.com",
|
|
5
5
|
"author": "BART! <bart@bartweb.cz>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"got-scraping": "^4.2.
|
|
8
|
+
"got-scraping": "^4.2.2",
|
|
9
9
|
"node-html-parser": "^7.1.0"
|
|
10
10
|
},
|
|
11
11
|
"repository": {
|
|
@@ -32,9 +32,19 @@
|
|
|
32
32
|
"node": ">= 20"
|
|
33
33
|
},
|
|
34
34
|
"license": "MIT",
|
|
35
|
+
"main": "./index.js",
|
|
35
36
|
"types": "./index.d.ts",
|
|
37
|
+
"react-native": "./index.fetch.js",
|
|
38
|
+
"browser": "./index.fetch.js",
|
|
36
39
|
"exports": {
|
|
37
|
-
".":
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./index.d.ts",
|
|
42
|
+
"workerd": "./index.fetch.js",
|
|
43
|
+
"worker": "./index.fetch.js",
|
|
44
|
+
"react-native": "./index.fetch.js",
|
|
45
|
+
"browser": "./index.fetch.js",
|
|
46
|
+
"default": "./index.js"
|
|
47
|
+
},
|
|
38
48
|
"./package.json": "./package.json"
|
|
39
49
|
}
|
|
40
50
|
}
|