atlas-obscura-api 3.2.0 → 4.0.0-next.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/index.d.mts +91 -0
- package/index.d.ts +91 -14
- package/index.js +158 -26
- package/index.js.map +1 -0
- package/index.mjs +134 -0
- package/index.mjs.map +1 -0
- package/package.json +11 -26
- package/README.md +0 -323
- package/fetchers/index.d.ts +0 -1
- package/fetchers/index.js +0 -33
- package/interfaces/global.d.ts +0 -7
- package/interfaces/global.js +0 -2
- package/interfaces/locations.interface.d.ts +0 -25
- package/interfaces/locations.interface.js +0 -2
- package/interfaces/placeId.interface.d.ts +0 -30
- package/interfaces/placeId.interface.js +0 -2
- package/interfaces/places-all.interface.d.ts +0 -4
- package/interfaces/places-all.interface.js +0 -2
- package/services/location.service.d.ts +0 -10
- package/services/location.service.js +0 -65
- package/utils.d.ts +0 -1
- package/utils.js +0 -16
- package/vars.d.ts +0 -6
- package/vars.js +0 -8
package/index.d.mts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
//#region src/interfaces/global.d.ts
|
|
2
|
+
interface Coordinates {
|
|
3
|
+
lat: number;
|
|
4
|
+
lng: number;
|
|
5
|
+
}
|
|
6
|
+
type FetchOptions = {
|
|
7
|
+
headers?: Headers;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/interfaces/locations.interface.d.ts
|
|
11
|
+
interface LocationResult {
|
|
12
|
+
total: Total;
|
|
13
|
+
per_page: number;
|
|
14
|
+
current_page: number;
|
|
15
|
+
location: string;
|
|
16
|
+
q: string;
|
|
17
|
+
coordinates: Coordinates;
|
|
18
|
+
results: Location[];
|
|
19
|
+
}
|
|
20
|
+
interface Location {
|
|
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: Coordinates;
|
|
29
|
+
distance_from_query: string;
|
|
30
|
+
}
|
|
31
|
+
interface Total {
|
|
32
|
+
value: number;
|
|
33
|
+
relation: string;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/interfaces/placeId.interface.d.ts
|
|
37
|
+
interface PlaceShort {
|
|
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: Coordinates;
|
|
50
|
+
nearby_places: PlaceShort[];
|
|
51
|
+
nearby_foods: PlaceShort[];
|
|
52
|
+
}
|
|
53
|
+
interface PlaceExtend {
|
|
54
|
+
description?: string[];
|
|
55
|
+
tags?: Tag[];
|
|
56
|
+
directions?: string[];
|
|
57
|
+
imageCover?: string;
|
|
58
|
+
images?: string[];
|
|
59
|
+
}
|
|
60
|
+
interface Tag {
|
|
61
|
+
title: string;
|
|
62
|
+
link: string;
|
|
63
|
+
}
|
|
64
|
+
interface Place extends PlaceShort, PlaceExtend {}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/interfaces/places-all.interface.d.ts
|
|
67
|
+
interface PlacesAll extends Coordinates {
|
|
68
|
+
id: number;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/services/location.service.d.ts
|
|
72
|
+
declare class PlacesScraper {
|
|
73
|
+
placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
|
|
74
|
+
search(coords: Coordinates, page?: number, options?: FetchOptions): Promise<LocationResult>;
|
|
75
|
+
placeByIdShort(id: number, options?: FetchOptions): Promise<PlaceShort>;
|
|
76
|
+
placeFull(url: string, options?: FetchOptions): Promise<PlaceExtend>;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/index.d.ts
|
|
80
|
+
declare class AtlasObscura {
|
|
81
|
+
private locationService;
|
|
82
|
+
constructor(locationService: PlacesScraper);
|
|
83
|
+
search(coords: Coordinates, options?: FetchOptions): Promise<LocationResult>;
|
|
84
|
+
placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
|
|
85
|
+
placeShort(id: number, options?: FetchOptions): Promise<PlaceShort>;
|
|
86
|
+
placeFull(id: number, options?: FetchOptions): Promise<Place>;
|
|
87
|
+
}
|
|
88
|
+
declare const atlasobscura: AtlasObscura;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { AtlasObscura, atlasobscura };
|
|
91
|
+
//# sourceMappingURL=index.d.mts.map
|
package/index.d.ts
CHANGED
|
@@ -1,14 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
//#region src/interfaces/global.d.ts
|
|
2
|
+
interface Coordinates {
|
|
3
|
+
lat: number;
|
|
4
|
+
lng: number;
|
|
5
|
+
}
|
|
6
|
+
type FetchOptions = {
|
|
7
|
+
headers?: Headers;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/interfaces/locations.interface.d.ts
|
|
11
|
+
interface LocationResult {
|
|
12
|
+
total: Total;
|
|
13
|
+
per_page: number;
|
|
14
|
+
current_page: number;
|
|
15
|
+
location: string;
|
|
16
|
+
q: string;
|
|
17
|
+
coordinates: Coordinates;
|
|
18
|
+
results: Location[];
|
|
19
|
+
}
|
|
20
|
+
interface Location {
|
|
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: Coordinates;
|
|
29
|
+
distance_from_query: string;
|
|
30
|
+
}
|
|
31
|
+
interface Total {
|
|
32
|
+
value: number;
|
|
33
|
+
relation: string;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/interfaces/placeId.interface.d.ts
|
|
37
|
+
interface PlaceShort {
|
|
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: Coordinates;
|
|
50
|
+
nearby_places: PlaceShort[];
|
|
51
|
+
nearby_foods: PlaceShort[];
|
|
52
|
+
}
|
|
53
|
+
interface PlaceExtend {
|
|
54
|
+
description?: string[];
|
|
55
|
+
tags?: Tag[];
|
|
56
|
+
directions?: string[];
|
|
57
|
+
imageCover?: string;
|
|
58
|
+
images?: string[];
|
|
59
|
+
}
|
|
60
|
+
interface Tag {
|
|
61
|
+
title: string;
|
|
62
|
+
link: string;
|
|
63
|
+
}
|
|
64
|
+
interface Place extends PlaceShort, PlaceExtend {}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/interfaces/places-all.interface.d.ts
|
|
67
|
+
interface PlacesAll extends Coordinates {
|
|
68
|
+
id: number;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/services/location.service.d.ts
|
|
72
|
+
declare class PlacesScraper {
|
|
73
|
+
placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
|
|
74
|
+
search(coords: Coordinates, page?: number, options?: FetchOptions): Promise<LocationResult>;
|
|
75
|
+
placeByIdShort(id: number, options?: FetchOptions): Promise<PlaceShort>;
|
|
76
|
+
placeFull(url: string, options?: FetchOptions): Promise<PlaceExtend>;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/index.d.ts
|
|
80
|
+
declare class AtlasObscura {
|
|
81
|
+
private locationService;
|
|
82
|
+
constructor(locationService: PlacesScraper);
|
|
83
|
+
search(coords: Coordinates, options?: FetchOptions): Promise<LocationResult>;
|
|
84
|
+
placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
|
|
85
|
+
placeShort(id: number, options?: FetchOptions): Promise<PlaceShort>;
|
|
86
|
+
placeFull(id: number, options?: FetchOptions): Promise<Place>;
|
|
87
|
+
}
|
|
88
|
+
declare const atlasobscura: AtlasObscura;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { AtlasObscura, atlasobscura };
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,27 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let node_html_parser = require("node-html-parser");
|
|
25
|
+
node_html_parser = __toESM(node_html_parser);
|
|
26
|
+
|
|
27
|
+
//#region src/fetchers/index.ts
|
|
28
|
+
const USER_AGENTS = [
|
|
29
|
+
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; C6L Build/OPM2.171019.012)",
|
|
30
|
+
"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",
|
|
31
|
+
"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",
|
|
32
|
+
"Dalvik/2.1.0 (Linux; U; Android 11; SM-A505GT Build/RP1A.200720.012)",
|
|
33
|
+
"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",
|
|
34
|
+
"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",
|
|
35
|
+
"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",
|
|
36
|
+
"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",
|
|
37
|
+
"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",
|
|
38
|
+
"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",
|
|
39
|
+
"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"
|
|
40
|
+
];
|
|
41
|
+
const DEFAULT_HEADERS = {
|
|
42
|
+
"User-Agent": USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],
|
|
43
|
+
"Cache-Control": "no-cache"
|
|
44
|
+
};
|
|
45
|
+
const fetchPage = async (url, headersCustom) => {
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(url, {
|
|
48
|
+
headers: {
|
|
49
|
+
...DEFAULT_HEADERS,
|
|
50
|
+
...headersCustom
|
|
51
|
+
},
|
|
52
|
+
credentials: "omit"
|
|
53
|
+
});
|
|
54
|
+
if (!response.ok) throw new Error(`atlas-obscura-api: Bad response ${response.status} for url: ${url}`);
|
|
55
|
+
return await response.text();
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error("fetchPage error:", error);
|
|
58
|
+
return "Error";
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/utils.ts
|
|
64
|
+
const parseResults = (matches) => {
|
|
65
|
+
let locations = null;
|
|
66
|
+
if (matches && matches[1]?.length) try {
|
|
67
|
+
locations = JSON.parse(matches[1]);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("Error parsing all places");
|
|
70
|
+
}
|
|
71
|
+
return locations;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/vars.ts
|
|
76
|
+
const URL_PLACES_ALL = "https://www.atlasobscura.com/articles/all-places-in-the-atlas-on-one-map";
|
|
77
|
+
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 : ""}`;
|
|
78
|
+
const urlPlaceId = (id) => `https://www.atlasobscura.com/places/${id}.json?place_only=1`;
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/services/location.service.ts
|
|
82
|
+
var PlacesScraper = class {
|
|
83
|
+
async placesAll(options) {
|
|
84
|
+
return parseResults((0, node_html_parser.parse)(await fetchPage(URL_PLACES_ALL, options?.headers)).innerHTML.match(/AtlasObscura\.all_places = (.*?);/));
|
|
85
|
+
}
|
|
86
|
+
async search(coords, page = 1, options) {
|
|
87
|
+
return parseResults((0, node_html_parser.parse)(await fetchPage(urlSearch(coords, page), options?.headers)).innerHTML.match(/AtlasObscura\.place_search = (.*?);/));
|
|
88
|
+
}
|
|
89
|
+
async placeByIdShort(id, options) {
|
|
90
|
+
const data = await fetchPage(urlPlaceId(id), options?.headers);
|
|
91
|
+
let place = null;
|
|
92
|
+
try {
|
|
93
|
+
place = JSON.parse(data);
|
|
94
|
+
if (place && typeof place.hide_from_maps === "string") place.hide_from_maps = place.hide_from_maps === "true";
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error("Error parsing placeById", id);
|
|
97
|
+
}
|
|
98
|
+
return place;
|
|
99
|
+
}
|
|
100
|
+
async placeFull(url, options) {
|
|
101
|
+
const html = (0, node_html_parser.parse)(await fetchPage(url, options?.headers));
|
|
102
|
+
const descriptions = html.querySelectorAll(".place-body p").map((p) => p.innerHTML);
|
|
103
|
+
const sectionDirections = Array.from(html.querySelectorAll("section")).find((sec) => {
|
|
104
|
+
const h2 = sec.querySelector("h2");
|
|
105
|
+
return h2 && h2.textContent.trim() === "Know Before You Go";
|
|
106
|
+
});
|
|
107
|
+
const directions = sectionDirections ? Array.from(sectionDirections.querySelectorAll("p")).map((p) => p.textContent.trim()) : [];
|
|
108
|
+
const tags = html.querySelectorAll(".aon-pill-badge-component").map((x) => {
|
|
109
|
+
return {
|
|
110
|
+
title: x.querySelector(".aon-pill-badge-text")?.innerHTML.trim(),
|
|
111
|
+
link: x.attributes.href
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
const slides = html.querySelectorAll(".swiper-slide");
|
|
115
|
+
const images = Array.from(slides).map((slide) => {
|
|
116
|
+
const img = slide.querySelector("img");
|
|
117
|
+
return img ? img.getAttribute("src") : null;
|
|
118
|
+
}).filter(Boolean);
|
|
119
|
+
return {
|
|
120
|
+
description: descriptions,
|
|
121
|
+
directions,
|
|
122
|
+
tags,
|
|
123
|
+
imageCover: images[0],
|
|
124
|
+
images
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/index.ts
|
|
131
|
+
var AtlasObscura = class {
|
|
132
|
+
constructor(locationService) {
|
|
133
|
+
this.locationService = locationService;
|
|
134
|
+
}
|
|
135
|
+
async search(coords, options) {
|
|
136
|
+
return this.locationService.search(coords, 1, options);
|
|
137
|
+
}
|
|
138
|
+
async placesAll(options) {
|
|
139
|
+
return this.locationService.placesAll(options);
|
|
140
|
+
}
|
|
141
|
+
async placeShort(id, options) {
|
|
142
|
+
return this.locationService.placeByIdShort(id, options);
|
|
143
|
+
}
|
|
144
|
+
async placeFull(id, options) {
|
|
145
|
+
const place = await this.locationService.placeByIdShort(id, options);
|
|
146
|
+
const placeRich = await this.locationService.placeFull(place.url, options);
|
|
147
|
+
return {
|
|
148
|
+
...place,
|
|
149
|
+
...placeRich
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const locationScraper = new PlacesScraper();
|
|
154
|
+
const atlasobscura = new AtlasObscura(locationScraper);
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
25
157
|
exports.AtlasObscura = AtlasObscura;
|
|
26
|
-
|
|
27
|
-
|
|
158
|
+
exports.atlasobscura = atlasobscura;
|
|
159
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["USER_AGENTS: string[]","locations: T","place: PlaceShort","locationService: PlacesScraper","atlasobscura: AtlasObscura"],"sources":["../src/fetchers/index.ts","../src/utils.ts","../src/vars.ts","../src/services/location.service.ts","../src/index.ts"],"sourcesContent":["const 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 = {\n 'User-Agent': USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],\n 'Cache-Control': 'no-cache',\n};\n\nexport const fetchPage = async (url: string, headersCustom?: Headers): Promise<string> => {\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","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","import { parse } from 'node-html-parser';\nimport { fetchPage } from '../fetchers/index.js';\nimport { parseResults } from '../utils.js';\nimport { URL_PLACES_ALL, urlPlaceId, urlSearch } from '../vars.js';\nimport { Coordinates, FetchOptions } from './../interfaces/global.js';\nimport { LocationResult } from './../interfaces/locations.interface.js';\nimport { PlaceExtend, PlaceShort } from './../interfaces/placeId.interface.js';\nimport { PlacesAll } from './../interfaces/places-all.interface.js';\n\nexport class PlacesScraper {\n public async placesAll(options?: FetchOptions): Promise<PlacesAll[]> {\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<PlacesAll[]>(data);\n }\n\n public async search(coords: Coordinates, page = 1, options?: FetchOptions): Promise<LocationResult> {\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<LocationResult>(data);\n }\n\n public async placeByIdShort(id: number, options?: FetchOptions): Promise<PlaceShort> {\n const url = urlPlaceId(id);\n const data = await fetchPage(url, options?.headers);\n\n let place: PlaceShort = 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?: FetchOptions): Promise<PlaceExtend> {\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","import { Coordinates, FetchOptions } from './interfaces/global.js';\nimport { LocationResult } from './interfaces/locations.interface.js';\nimport { Place, PlaceShort } from './interfaces/placeId.interface.js';\nimport { PlacesAll } from './interfaces/places-all.interface.js';\nimport { PlacesScraper } from './services/location.service.js';\n\nexport class AtlasObscura {\n constructor(private locationService: PlacesScraper) { }\n\n public async search(coords: Coordinates, options?: FetchOptions): Promise<LocationResult> {\n return this.locationService.search(coords, 1, options);\n }\n\n public async placesAll(options?: FetchOptions): Promise<PlacesAll[]> {\n return this.locationService.placesAll(options);\n }\n\n public async placeShort(id: number, options?: FetchOptions): Promise<PlaceShort> {\n return this.locationService.placeByIdShort(id, options);\n }\n\n public async placeFull(id: number, options?: FetchOptions): Promise<Place> {\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\nconst locationScraper = new PlacesScraper();\nexport const atlasobscura: AtlasObscura = new AtlasObscura(locationScraper);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAMA,cAAwB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,kBAAkB;CACtB,cAAc,YAAY,KAAK,MAAM,KAAK,QAAQ,GAAG,YAAY,OAAO;CACxE,iBAAiB;CAClB;AAED,MAAa,YAAY,OAAO,KAAa,kBAA6C;AACxF,KAAI;EACF,MAAM,WAAW,MAAM,MAAM,KAAK;GAChC,SAAS;IAAE,GAAG;IAAiB,GAAG;IAAe;GACjD,aAAa;GACd,CAAC;AAEF,MAAI,CAAC,SAAS,GACZ,OAAM,IAAI,MAAM,mCAAmC,SAAS,OAAO,YAAY,MAAM;AAGvF,SAAO,MAAM,SAAS,MAAM;UACrB,OAAO;AACd,UAAQ,MAAM,oBAAoB,MAAM;AACxC,SAAO;;;;;;ACjCX,MAAa,gBAAmB,YAAiC;CAC/D,IAAIC,YAAe;AAEnB,KAAI,WAAW,QAAQ,IAAI,OACzB,KAAI;AACF,cAAY,KAAK,MAAM,QAAQ,GAAG;UAC3B,OAAO;AACd,UAAQ,MAAM,2BAA2B;;AAG7C,QAAO;;;;;ACVT,MAAa,iBACX;AAEF,MAAa,aAAa,OAAqC,SAC7D,mFAAmF,MAAM,IACxF,OAAO,MAAM,MAAM,OAAO,WAAW,OAAO;AAE/C,MAAa,cAAc,OACzB,uCAAuC,GAAG;;;;ACC5C,IAAa,gBAAb,MAA2B;CACzB,MAAa,UAAU,SAA8C;AAMnE,SAAO,yCALU,MAAM,UAAU,gBAAgB,SAAS,QAAQ,CACtC,CAAC,UAEX,MAAM,oCAAoC,CAEtB;;CAGxC,MAAa,OAAO,QAAqB,OAAO,GAAG,SAAiD;AAOlG,SAAO,yCALU,MAAM,UADX,UAAU,QAAQ,KAAK,EACG,SAAS,QAAQ,CAC3B,CAAC,UAEX,MAAM,sCAAsC,CAErB;;CAG3C,MAAa,eAAe,IAAY,SAA6C;EAEnF,MAAM,OAAO,MAAM,UADP,WAAW,GAAG,EACQ,SAAS,QAAQ;EAEnD,IAAIC,QAAoB;AAExB,MAAI;AACF,WAAQ,KAAK,MAAM,KAAK;AACxB,OAAI,SAAS,OAAO,MAAM,mBAAmB,SAC3C,CAAC,MAAc,iBAAiB,MAAM,mBAAmB;WAEpD,OAAO;AACd,WAAQ,MAAM,2BAA2B,GAAG;;AAE9C,SAAO;;CAGT,MAAa,UAAU,KAAa,SAA8C;EAEhF,MAAM,mCADO,MAAM,UAAU,KAAK,SAAS,QAAQ,CAC3B;EAExB,MAAM,eAAe,KAAK,iBAAiB,gBAAgB,CAAC,KAAK,MAAM,EAAE,UAAU;EAEnF,MAAM,oBAAoB,MAAM,KAAK,KAAK,iBAAiB,UAAU,CAAC,CAAC,MAAM,QAAQ;GACnF,MAAM,KAAK,IAAI,cAAc,KAAK;AAClC,UAAO,MAAM,GAAG,YAAY,MAAM,KAAK;IACvC;EACF,MAAM,aAAa,oBACf,MAAM,KAAK,kBAAkB,iBAAiB,IAAI,CAAC,CAAC,KAAK,MAAM,EAAE,YAAY,MAAM,CAAC,GACpF,EAAE;EAEN,MAAM,OAAO,KAAK,iBAAiB,4BAA4B,CAAC,KAAK,MAAM;AACzE,UAAO;IACL,OAAO,EAAE,cAAc,uBAAuB,EAAE,UAAU,MAAM;IAChE,MAAM,EAAE,WAAW;IACpB;IACD;EAEF,MAAM,SAAS,KAAK,iBAAiB,gBAAgB;EACrD,MAAM,SAAS,MAAM,KAAK,OAAO,CAC9B,KAAK,UAAU;GACd,MAAM,MAAM,MAAM,cAAc,MAAM;AACtC,UAAO,MAAM,IAAI,aAAa,MAAM,GAAG;IACvC,CACD,OAAO,QAAQ;AAIlB,SAAO;GAAE,aAAa;GAAc;GAAY;GAAM,YAFnC,OAAO;GAEwC;GAAQ;;;;;;ACvE9E,IAAa,eAAb,MAA0B;CACxB,YAAY,AAAQC,iBAAgC;EAAhC;;CAEpB,MAAa,OAAO,QAAqB,SAAiD;AACxF,SAAO,KAAK,gBAAgB,OAAO,QAAQ,GAAG,QAAQ;;CAGxD,MAAa,UAAU,SAA8C;AACnE,SAAO,KAAK,gBAAgB,UAAU,QAAQ;;CAGhD,MAAa,WAAW,IAAY,SAA6C;AAC/E,SAAO,KAAK,gBAAgB,eAAe,IAAI,QAAQ;;CAGzD,MAAa,UAAU,IAAY,SAAwC;EACzE,MAAM,QAAQ,MAAM,KAAK,gBAAgB,eAAe,IAAI,QAAQ;EACpE,MAAM,YAAY,MAAM,KAAK,gBAAgB,UAAU,MAAM,KAAK,QAAQ;AAC1E,SAAO;GAAE,GAAG;GAAO,GAAG;GAAW;;;AAIrC,MAAM,kBAAkB,IAAI,eAAe;AAC3C,MAAaC,eAA6B,IAAI,aAAa,gBAAgB"}
|
package/index.mjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { parse } from "node-html-parser";
|
|
2
|
+
|
|
3
|
+
//#region src/fetchers/index.ts
|
|
4
|
+
const USER_AGENTS = [
|
|
5
|
+
"Dalvik/2.1.0 (Linux; U; Android 8.1.0; C6L Build/OPM2.171019.012)",
|
|
6
|
+
"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",
|
|
7
|
+
"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",
|
|
8
|
+
"Dalvik/2.1.0 (Linux; U; Android 11; SM-A505GT Build/RP1A.200720.012)",
|
|
9
|
+
"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",
|
|
10
|
+
"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",
|
|
11
|
+
"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",
|
|
12
|
+
"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",
|
|
13
|
+
"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",
|
|
14
|
+
"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",
|
|
15
|
+
"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"
|
|
16
|
+
];
|
|
17
|
+
const DEFAULT_HEADERS = {
|
|
18
|
+
"User-Agent": USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],
|
|
19
|
+
"Cache-Control": "no-cache"
|
|
20
|
+
};
|
|
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
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/utils.ts
|
|
40
|
+
const parseResults = (matches) => {
|
|
41
|
+
let locations = null;
|
|
42
|
+
if (matches && matches[1]?.length) try {
|
|
43
|
+
locations = JSON.parse(matches[1]);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Error parsing all places");
|
|
46
|
+
}
|
|
47
|
+
return locations;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/vars.ts
|
|
52
|
+
const URL_PLACES_ALL = "https://www.atlasobscura.com/articles/all-places-in-the-atlas-on-one-map";
|
|
53
|
+
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 : ""}`;
|
|
54
|
+
const urlPlaceId = (id) => `https://www.atlasobscura.com/places/${id}.json?place_only=1`;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/services/location.service.ts
|
|
58
|
+
var PlacesScraper = class {
|
|
59
|
+
async placesAll(options) {
|
|
60
|
+
return parseResults(parse(await fetchPage(URL_PLACES_ALL, options?.headers)).innerHTML.match(/AtlasObscura\.all_places = (.*?);/));
|
|
61
|
+
}
|
|
62
|
+
async search(coords, page = 1, options) {
|
|
63
|
+
return parseResults(parse(await fetchPage(urlSearch(coords, page), options?.headers)).innerHTML.match(/AtlasObscura\.place_search = (.*?);/));
|
|
64
|
+
}
|
|
65
|
+
async placeByIdShort(id, options) {
|
|
66
|
+
const data = await fetchPage(urlPlaceId(id), options?.headers);
|
|
67
|
+
let place = null;
|
|
68
|
+
try {
|
|
69
|
+
place = JSON.parse(data);
|
|
70
|
+
if (place && typeof place.hide_from_maps === "string") place.hide_from_maps = place.hide_from_maps === "true";
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error("Error parsing placeById", id);
|
|
73
|
+
}
|
|
74
|
+
return place;
|
|
75
|
+
}
|
|
76
|
+
async placeFull(url, options) {
|
|
77
|
+
const html = parse(await fetchPage(url, options?.headers));
|
|
78
|
+
const descriptions = html.querySelectorAll(".place-body p").map((p) => p.innerHTML);
|
|
79
|
+
const sectionDirections = Array.from(html.querySelectorAll("section")).find((sec) => {
|
|
80
|
+
const h2 = sec.querySelector("h2");
|
|
81
|
+
return h2 && h2.textContent.trim() === "Know Before You Go";
|
|
82
|
+
});
|
|
83
|
+
const directions = sectionDirections ? Array.from(sectionDirections.querySelectorAll("p")).map((p) => p.textContent.trim()) : [];
|
|
84
|
+
const tags = html.querySelectorAll(".aon-pill-badge-component").map((x) => {
|
|
85
|
+
return {
|
|
86
|
+
title: x.querySelector(".aon-pill-badge-text")?.innerHTML.trim(),
|
|
87
|
+
link: x.attributes.href
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
const slides = html.querySelectorAll(".swiper-slide");
|
|
91
|
+
const images = Array.from(slides).map((slide) => {
|
|
92
|
+
const img = slide.querySelector("img");
|
|
93
|
+
return img ? img.getAttribute("src") : null;
|
|
94
|
+
}).filter(Boolean);
|
|
95
|
+
return {
|
|
96
|
+
description: descriptions,
|
|
97
|
+
directions,
|
|
98
|
+
tags,
|
|
99
|
+
imageCover: images[0],
|
|
100
|
+
images
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/index.ts
|
|
107
|
+
var AtlasObscura = class {
|
|
108
|
+
constructor(locationService) {
|
|
109
|
+
this.locationService = locationService;
|
|
110
|
+
}
|
|
111
|
+
async search(coords, options) {
|
|
112
|
+
return this.locationService.search(coords, 1, options);
|
|
113
|
+
}
|
|
114
|
+
async placesAll(options) {
|
|
115
|
+
return this.locationService.placesAll(options);
|
|
116
|
+
}
|
|
117
|
+
async placeShort(id, options) {
|
|
118
|
+
return this.locationService.placeByIdShort(id, options);
|
|
119
|
+
}
|
|
120
|
+
async placeFull(id, options) {
|
|
121
|
+
const place = await this.locationService.placeByIdShort(id, options);
|
|
122
|
+
const placeRich = await this.locationService.placeFull(place.url, options);
|
|
123
|
+
return {
|
|
124
|
+
...place,
|
|
125
|
+
...placeRich
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const locationScraper = new PlacesScraper();
|
|
130
|
+
const atlasobscura = new AtlasObscura(locationScraper);
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { AtlasObscura, atlasobscura };
|
|
134
|
+
//# sourceMappingURL=index.mjs.map
|
package/index.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["USER_AGENTS: string[]","locations: T","place: PlaceShort","locationService: PlacesScraper","atlasobscura: AtlasObscura"],"sources":["../src/fetchers/index.ts","../src/utils.ts","../src/vars.ts","../src/services/location.service.ts","../src/index.ts"],"sourcesContent":["const 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 = {\n 'User-Agent': USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],\n 'Cache-Control': 'no-cache',\n};\n\nexport const fetchPage = async (url: string, headersCustom?: Headers): Promise<string> => {\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","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","import { parse } from 'node-html-parser';\nimport { fetchPage } from '../fetchers/index.js';\nimport { parseResults } from '../utils.js';\nimport { URL_PLACES_ALL, urlPlaceId, urlSearch } from '../vars.js';\nimport { Coordinates, FetchOptions } from './../interfaces/global.js';\nimport { LocationResult } from './../interfaces/locations.interface.js';\nimport { PlaceExtend, PlaceShort } from './../interfaces/placeId.interface.js';\nimport { PlacesAll } from './../interfaces/places-all.interface.js';\n\nexport class PlacesScraper {\n public async placesAll(options?: FetchOptions): Promise<PlacesAll[]> {\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<PlacesAll[]>(data);\n }\n\n public async search(coords: Coordinates, page = 1, options?: FetchOptions): Promise<LocationResult> {\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<LocationResult>(data);\n }\n\n public async placeByIdShort(id: number, options?: FetchOptions): Promise<PlaceShort> {\n const url = urlPlaceId(id);\n const data = await fetchPage(url, options?.headers);\n\n let place: PlaceShort = 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?: FetchOptions): Promise<PlaceExtend> {\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","import { Coordinates, FetchOptions } from './interfaces/global.js';\nimport { LocationResult } from './interfaces/locations.interface.js';\nimport { Place, PlaceShort } from './interfaces/placeId.interface.js';\nimport { PlacesAll } from './interfaces/places-all.interface.js';\nimport { PlacesScraper } from './services/location.service.js';\n\nexport class AtlasObscura {\n constructor(private locationService: PlacesScraper) { }\n\n public async search(coords: Coordinates, options?: FetchOptions): Promise<LocationResult> {\n return this.locationService.search(coords, 1, options);\n }\n\n public async placesAll(options?: FetchOptions): Promise<PlacesAll[]> {\n return this.locationService.placesAll(options);\n }\n\n public async placeShort(id: number, options?: FetchOptions): Promise<PlaceShort> {\n return this.locationService.placeByIdShort(id, options);\n }\n\n public async placeFull(id: number, options?: FetchOptions): Promise<Place> {\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\nconst locationScraper = new PlacesScraper();\nexport const atlasobscura: AtlasObscura = new AtlasObscura(locationScraper);\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atlas-obscura-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-next.0",
|
|
4
4
|
"description": "Atlas Obscura API in JavaScript. NPM library for scrapping atlasobscura.com",
|
|
5
|
-
"main": "./index.js",
|
|
6
5
|
"author": "BART! <bart@bartweb.cz>",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "tsc -w",
|
|
9
|
-
"prebuild": "rimraf dist",
|
|
10
|
-
"build": "tsc && npm-prepare-dist -s postinstall -s prepare",
|
|
11
|
-
"tsc": "tsc",
|
|
12
|
-
"demo": "tsx demo",
|
|
13
|
-
"lint": "eslint ./src/**/**/* --fix",
|
|
14
|
-
"test": "vitest",
|
|
15
|
-
"test:coverage": "yarn test run --coverage",
|
|
16
|
-
"publish:next": "yarn && yarn build && yarn test --coverage && npm publish --folder dist --tag beta",
|
|
17
|
-
"postversion": "git push && git push --follow-tags",
|
|
18
|
-
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
19
|
-
"prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
|
|
20
|
-
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
|
|
21
|
-
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
|
|
22
|
-
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
|
|
23
|
-
},
|
|
24
6
|
"dependencies": {
|
|
25
|
-
"cross-fetch": "^4.1.0",
|
|
26
7
|
"node-html-parser": "^7.0.1"
|
|
27
8
|
},
|
|
28
9
|
"repository": {
|
|
@@ -49,10 +30,14 @@
|
|
|
49
30
|
"node": ">= 20"
|
|
50
31
|
},
|
|
51
32
|
"license": "MIT",
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
33
|
+
"main": "./index.js",
|
|
34
|
+
"module": "./index.mjs",
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": "./index.mjs",
|
|
39
|
+
"require": "./index.js"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
}
|
|
58
43
|
}
|
package/README.md
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
[](https://badge.fury.io/js/atlas-obscura-api)
|
|
2
|
-
[](https://www.npmjs.com/atlas-obscura-api)
|
|
3
|
-
[](https://github.com/bartholomej/atlas-obscura-api/actions)
|
|
4
|
-
[](https://codecov.io/gh/bartholomej/atlas-obscura-api)
|
|
5
|
-
|
|
6
|
-
# Atlas Obscura API (Scraper)
|
|
7
|
-
|
|
8
|
-
> JavaScript NPM library for scraping **Atlas Obscura ([atlasobscura.com](https://atlasobscura.com))** [unofficial]
|
|
9
|
-
>
|
|
10
|
-
> - Browser + Node.js (SSR)
|
|
11
|
-
> - JavaScript / TypeScript
|
|
12
|
-
> - You can use in:
|
|
13
|
-
> - Firebase function
|
|
14
|
-
> - AWS λ (lambda function)
|
|
15
|
-
> - Chrome extension
|
|
16
|
-
> - React native app
|
|
17
|
-
> - Docker container
|
|
18
|
-
> - ...
|
|
19
|
-
|
|
20
|
-
## 📦 Installation
|
|
21
|
-
|
|
22
|
-
Install the library using npm, yarn, or your preferred package manager:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install atlas-obscura-api --save
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 🚀 Usage and Examples
|
|
29
|
-
|
|
30
|
-
Explore how to use the library with practical code snippets and sample outputs below:
|
|
31
|
-
|
|
32
|
-
- [All places](#all-places)
|
|
33
|
-
- [Search](#search)
|
|
34
|
-
- [Show place by ID (short)](#short-version-one-quick-request)
|
|
35
|
-
- [Show place by ID (full)](#full-detail-two-internal-requests)
|
|
36
|
-
|
|
37
|
-
### All Places
|
|
38
|
-
|
|
39
|
-
> Retrieve all places locations
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
import { atlasobscura } from 'atlas-obscura-api';
|
|
43
|
-
|
|
44
|
-
atlasobscura.placesAll().then((places) => console.log(places));
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
#### Results
|
|
48
|
-
|
|
49
|
-
```javascript
|
|
50
|
-
[
|
|
51
|
-
{ id: 46691, lat: 29.99022, lng: -95.336783 },
|
|
52
|
-
{ id: 46850, lat: 36.709674, lng: -92.266472 },
|
|
53
|
-
{ id: 46597, lat: 32.805765, lng: 35.169971 },
|
|
54
|
-
{ id: 43701, lat: 54.415365, lng: -1.260063 },
|
|
55
|
-
{ id: 46266, lat: 46.196648, lng: 8.848537 },
|
|
56
|
-
{ id: 46282, lat: 46.236906, lng: -60.100201 },
|
|
57
|
-
{ id: 46028, lat: 21.272772, lng: -157.823812 },
|
|
58
|
-
{ id: 46736, lat: 39.635311, lng: -76.268685 },
|
|
59
|
-
{ id: 45981, lat: 34.101644, lng: -118.329489 },
|
|
60
|
-
{ id: 45455, lat: 42.929702, lng: -75.852011 },
|
|
61
|
-
{ id: 46206, lat: 38.912474, lng: -77.037291 },
|
|
62
|
-
{ id: 46081, lat: 32.930318, lng: -110.709229 }
|
|
63
|
-
];
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Search
|
|
67
|
-
|
|
68
|
-
> Search places by coordinates
|
|
69
|
-
|
|
70
|
-
```javascript
|
|
71
|
-
import { atlasobscura } from 'atlas-obscura-api';
|
|
72
|
-
|
|
73
|
-
atlasobscura.search({ lat: 34.0522, lng: -118.2437 }).then((search) => console.log(search));
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
#### Results
|
|
77
|
-
|
|
78
|
-
```javascript
|
|
79
|
-
[
|
|
80
|
-
{
|
|
81
|
-
title: 'Cathedral of Our Lady of the Angels',
|
|
82
|
-
subtitle:
|
|
83
|
-
"Crypt mausoleum in cathedral's basement contains relics of third century Roman martyr, Saint Vibiana.",
|
|
84
|
-
location: 'Los Angeles, California',
|
|
85
|
-
thumbnail_url:
|
|
86
|
-
'https://img.atlasobscura.com/YmNZy_5DUKw21Ppt5B4Ik8zo4qjrc9RkkgT1tnAghcE/rs:fill:200:200:1/g:ce/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy8yMTky/MDAyOTQxXzEzNDEw/OTQxMDguanBn.jpg',
|
|
87
|
-
url: '/places/cathedral-our-lady-angels',
|
|
88
|
-
id: 1370,
|
|
89
|
-
hide_from_maps: false,
|
|
90
|
-
coordinates: { lat: 34.05765, lng: -118.244944 },
|
|
91
|
-
distance_from_query: '0.38'
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
title: 'The Last Bookstore',
|
|
95
|
-
subtitle: 'This iconic L.A. bookshop is housed in an abandoned bank—both symbolic and chic.',
|
|
96
|
-
location: 'Los Angeles, California',
|
|
97
|
-
thumbnail_url:
|
|
98
|
-
'https://img.atlasobscura.com/6XpPQSE2YVsqTDOuvfx9ZHsYY0NfmX7oLzEUL87DL4A/rs:fill:200:200:1/g:ce/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy8xMmI0/MzBkMDJjZjc2MjBj/ODJfbGIxLmpwZw.jpg',
|
|
99
|
-
url: '/places/last-bookstore',
|
|
100
|
-
id: 6159,
|
|
101
|
-
hide_from_maps: false,
|
|
102
|
-
coordinates: { lat: 34.047738, lng: -118.249422 },
|
|
103
|
-
distance_from_query: '0.45'
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
title: 'Wells Fargo History Museum',
|
|
107
|
-
subtitle:
|
|
108
|
-
'Hidden in one of the skyscrapers on Bunker Hill, this museum features an 1895 stagecoach and peers into California’s gold-lined history.',
|
|
109
|
-
location: 'Los Angeles, California',
|
|
110
|
-
thumbnail_url:
|
|
111
|
-
'https://img.atlasobscura.com/27GLJ0vkGogC-l1AK5CuJKxS5FrBcNrcOROTWja4FAc/rs:fill:200:200:1/g:ce/c:2483:1655:nowe:2:126/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy80Mjg4/ZWJjZC0zYmNhLTQw/MTgtYTMzOC0wMTkz/M2FjNzVmZGIxMmQ4/MmVlYTgyY2IwMTM4/NTZfSU1HXzIwMTgw/ODI5XzE0NTE0NS5q/cGc.jpg',
|
|
112
|
-
url: '/places/wells-fargo-history-museum-los-angeles',
|
|
113
|
-
id: 28174,
|
|
114
|
-
hide_from_maps: false,
|
|
115
|
-
coordinates: { lat: 34.05283, lng: -118.25191 },
|
|
116
|
-
distance_from_query: '0.47'
|
|
117
|
-
}
|
|
118
|
-
];
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Show Place by ID
|
|
122
|
-
|
|
123
|
-
#### Short Version (One Quick Request)
|
|
124
|
-
|
|
125
|
-
> Get place by id (short version)
|
|
126
|
-
|
|
127
|
-
```javascript
|
|
128
|
-
import { atlasobscura } from 'atlas-obscura-api';
|
|
129
|
-
|
|
130
|
-
atlasobscura.placeShort(494).then((place) => console.log(place));
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
#### Results
|
|
134
|
-
|
|
135
|
-
```javascript
|
|
136
|
-
{
|
|
137
|
-
id: 494,
|
|
138
|
-
title: 'Bodie State Historic Park',
|
|
139
|
-
subtitle: 'Standing in a state of "arrested decay," this ghost town allows for a detailed peek into Gold Rush life in an unusually harsh climate.',
|
|
140
|
-
city: 'Bridgeport',
|
|
141
|
-
country: 'United States',
|
|
142
|
-
location: 'Bridgeport, California',
|
|
143
|
-
url: 'https://www.atlasobscura.com/places/bodie-state-historical-park',
|
|
144
|
-
hide_from_maps: false,
|
|
145
|
-
physical_status: '',
|
|
146
|
-
thumbnail_url: 'https://img.atlasobscura.com/DzPFF3feclAXS5apzZq6HqIgaKUSxGzIEKTfCpnfKxY/rs:fill:200:200:1/g:ce/c:815:543:nowe:0:633/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85MDY0/ZDNkODljYjdmNjI0/ZWViMzA0NjU0ZjM4/ZGI5MTYzODVkZTRh/LmpwZw.jpg',
|
|
147
|
-
thumbnail_url_3x2: 'https://img.atlasobscura.com/uCGcoetx8YfBtMOBo4oe1_6wUF7CM8AOK3L04aN9cg0/rs:fill:204:136:1/g:ce/c:815:543:nowe:0:633/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85MDY0/ZDNkODljYjdmNjI0/ZWViMzA0NjU0ZjM4/ZGI5MTYzODVkZTRh/LmpwZw.jpg',
|
|
148
|
-
coordinates: { lat: 38.208804, lng: -119.014163 },
|
|
149
|
-
nearby_places: [],
|
|
150
|
-
nearby_foods: []
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
#### Full Detail (Two Internal Requests)
|
|
155
|
-
|
|
156
|
-
> Get place by ID (FULL version).
|
|
157
|
-
>
|
|
158
|
-
> Beware: it makes two requests internally
|
|
159
|
-
|
|
160
|
-
```javascript
|
|
161
|
-
import { atlasobscura } from 'atlas-obscura-api';
|
|
162
|
-
|
|
163
|
-
atlasobscura.placeFull(494).then((place) => console.log(place));
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### Results
|
|
167
|
-
|
|
168
|
-
```javascript
|
|
169
|
-
{
|
|
170
|
-
id: 494,
|
|
171
|
-
title: 'Bodie State Historic Park',
|
|
172
|
-
subtitle: 'Standing in a state of "arrested decay," this ghost town allows for a detailed peek into Gold Rush life in an unusually harsh climate.',
|
|
173
|
-
city: 'Bridgeport',
|
|
174
|
-
country: 'United States',
|
|
175
|
-
location: 'Bridgeport, California',
|
|
176
|
-
url: 'https://www.atlasobscura.com/places/bodie-state-historical-park',
|
|
177
|
-
hide_from_maps: false,
|
|
178
|
-
physical_status: '',
|
|
179
|
-
thumbnail_url: 'https://img.atlasobscura.com/KaOCwrZAjNgS3LMOK28iuTxHDnMsl3Yjy0L_bYpfF1I/rs:fill:200:200:1/g:ce/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85MDY0/ZDNkODljYjdmNjI0/ZWViMzA0NjU0ZjM4/ZGI5MTYzODVkZTRh/LmpwZw.jpg',
|
|
180
|
-
thumbnail_url_3x2: 'https://img.atlasobscura.com/aH-Qf5bAn0PE1Y6gf0b1xHdteWwXY0G99dMtlMEdWVk/rs:fill:204:136:1/g:ce/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85MDY0/ZDNkODljYjdmNjI0/ZWViMzA0NjU0ZjM4/ZGI5MTYzODVkZTRh/LmpwZw.jpg',
|
|
181
|
-
coordinates: { lat: 38.208804, lng: -119.014163 },
|
|
182
|
-
description: [
|
|
183
|
-
'It was once the most lawless town in <a class="destination-link place-destination-link" href="https://www.atlasobscura.com/things-to-do/california">California</a>, a place where the fire bell ringing out the ages of those being laid to rest seemed to never stop its toll.',
|
|
184
|
-
"Today, what's left of Bodie is an eerie shell of the rough-and-tumble Gold Rush town, a window into a time long lost. Located in a very uniquely difficult climate of a desolate, high altitude plateau in the mountains but not in the woods, Bodie was not for the weak of heart—or feeble of constitutions.",
|
|
185
|
-
'Nestled in the Bodie Hills, east of the Sierra Nevada mountains just north of <a href="https://www.atlasobscura.com/places/mono-lake">Mono Lake</a>, Bodie grew quickly from a quiet town of 500 people to a rowdy mining city. Its population exploded during the second boom of the California gold rush and the beginning of the Nevada silver rush. By 1879, Bodie boasted a population of 10,000 and had 65 saloons, 50 mining companies, a thriving red-light district in the north end of town, and the worst reputation in the state.',
|
|
186
|
-
`Despite its nasty reputation, gold- and silver-seekers came from every corner of the country to this environment to "see the elephant," as heading West was called. Bodie's promise of gold and silver fortunes even attracted the likes of railroad tycoon Leland Stanford. With fortune hunters pouring in from all over the world, opium dens, brothels and gambling dens popped up for every flavor of wild west entertainment. They came for the gold and stayed for the party.`,
|
|
187
|
-
'Perhaps predictably, the mines quickly reached full capacity, and soon the mining companies cut their losses and closed down. Just as fast as Bodie had boomed, it busted, and the population had plummeted below 100 by 1888. Devoted locals held on until the 1920s, when Standard Mining closed down, but despite popular belief, Bodie was never completely abandoned. A few stragglers held down the fort until Bodie was absorbed as a National Landmark in 1962.',
|
|
188
|
-
'Today the windswept streets of Bodie are open to the public. It is the best-preserved ghost town in California, with about 200 structures remaining (about 5% of its original glory), along with rusted-out cars and machinery and boarded-up mines. Many of the building interiors still contain original artifacts and cannot be entered. The state is now restoring many of the buildings, as well as building more tourist-friendly walkways and restroom facilities.',
|
|
189
|
-
'Generally closed during the winter, the most reasonable access to Bodie is dusty highway 270, from highway 395. Call ahead during the swing months between winter and summer to check accessibility. Sometimes, a gate 1.5 miles out keeps away vehicles and advises hikers that the road is not fit to drive on.'
|
|
190
|
-
],
|
|
191
|
-
directions: [
|
|
192
|
-
'The Bodie Foundation runs a number of events every year. These include Friends of Bodie Day, which includes many historical reenactments; ghost walks; and photo workshops. The Stamp Mill, the only remaining industrial structure, is accessible only by guided tours. These tours can book up quickly. See Bodie Foundation link below for all listings. The park is northeast of Yosemite, 13 miles east of Highway 395 on Bodie Road (Hwy 270), seven miles south of Bridgeport.',
|
|
193
|
-
'Before you set out to visit Bodie, there are a few things you should consider. Because of its altitude Bodie is very cold. Temperatures drop below freezing point 300 days a year. Dress accordingly.',
|
|
194
|
-
'There is no gas station and no food for sale. So fill up your tank and pack a lunch.',
|
|
195
|
-
'If you love photography, bring all your gear with you.'
|
|
196
|
-
],
|
|
197
|
-
tags: [
|
|
198
|
-
{ title: 'Abandoned', link: '/categories/abandoned' },
|
|
199
|
-
{ title: 'Mining', link: '/categories/mining' },
|
|
200
|
-
{ title: 'Ghost Towns', link: '/categories/ghost-towns' },
|
|
201
|
-
{ title: 'Gold Rush', link: '/categories/gold-rush' },
|
|
202
|
-
{ title: 'Ruins', link: '/categories/ruins' }
|
|
203
|
-
],
|
|
204
|
-
imageCover: 'https://img.atlasobscura.com/Z7fkZefihgyRxzYQkbuv_xrdta4jxvASv_qBAfW_nYU/rt:fit/h:400/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85MDY0/ZDNkODljYjdmNjI0/ZWViMzA0NjU0ZjM4/ZGI5MTYzODVkZTRh/LmpwZw.jpg',
|
|
205
|
-
images: [
|
|
206
|
-
'https://img.atlasobscura.com/Z7fkZefihgyRxzYQkbuv_xrdta4jxvASv_qBAfW_nYU/rt:fit/h:400/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85MDY0/ZDNkODljYjdmNjI0/ZWViMzA0NjU0ZjM4/ZGI5MTYzODVkZTRh/LmpwZw.jpg',
|
|
207
|
-
'https://img.atlasobscura.com/a9V41OvE1zN7VchlVSGWtBSAcxfBT6GKrh-2UNbjzRU/rt:fit/h:400/q:81/sm:1/scp:1/ar:1/aHR0cHM6Ly9hdGxh/cy1kZXYuczMuYW1h/em9uYXdzLmNvbS91/cGxvYWRzL3BsYWNl/X2ltYWdlcy85dHR4/cDZiajVkNThlN2Zk/ZWQzMDNiMTA0MzI1/X0lNR185NDIyLlBO/Rw.jpg'
|
|
208
|
-
]
|
|
209
|
-
}
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## 📦 Docker
|
|
213
|
-
|
|
214
|
-
You can use this library in Docker.
|
|
215
|
-
|
|
216
|
-
We have [prepared a Docker image](https://hub.docker.com/r/bartholomej/atlas-obscura-api) for you.
|
|
217
|
-
|
|
218
|
-
### Prebuilt image
|
|
219
|
-
|
|
220
|
-
```bash
|
|
221
|
-
docker pull bartholomej/atlas-obscura-api
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Build & run your own image
|
|
225
|
-
|
|
226
|
-
> Build image
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
docker build -t atlas-obscura-api .
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
> Run image on port 3000
|
|
233
|
-
|
|
234
|
-
```bash
|
|
235
|
-
docker run -p 3000:3000 atlas-obscura-api
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
> Open http://localhost:3000
|
|
239
|
-
|
|
240
|
-
### API endpoints
|
|
241
|
-
|
|
242
|
-
> Some examples
|
|
243
|
-
|
|
244
|
-
- `/movie/535121`
|
|
245
|
-
- `/search/quentin+tarantino`
|
|
246
|
-
- `/creator/2120`
|
|
247
|
-
- `/user-ratings/912-bart`
|
|
248
|
-
|
|
249
|
-
## Used By
|
|
250
|
-
|
|
251
|
-
- Atlas Obscura Offline mobile app (Android, iOS)
|
|
252
|
-
- 🤷
|
|
253
|
-
|
|
254
|
-
## Development
|
|
255
|
-
|
|
256
|
-
### Developing and Debugging Library
|
|
257
|
-
|
|
258
|
-
Start the development server:
|
|
259
|
-
|
|
260
|
-
```bash
|
|
261
|
-
yarn start
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
### Run Demo Locally
|
|
265
|
-
|
|
266
|
-
You can find and modify it in [`./demo.ts`](https://github.com/bartholomej/atlas-obscura-api/blob/master/demo.ts) file:
|
|
267
|
-
|
|
268
|
-
```bash
|
|
269
|
-
yarn demo
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
## 📝 Development Notes
|
|
273
|
-
|
|
274
|
-
### Publish Stable
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
yarn release:patch
|
|
278
|
-
# yarn release:minor
|
|
279
|
-
# yarn release:major
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### Publish Next Channel
|
|
283
|
-
|
|
284
|
-
1. Bump version `-beta.0` in `package.json`
|
|
285
|
-
2. Run:
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
yarn release:beta
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
## Contribution
|
|
292
|
-
|
|
293
|
-
Contributions are welcome! Feel free to customize this library according to your needs.
|
|
294
|
-
|
|
295
|
-
Pull requests for any improvements are greatly appreciated!
|
|
296
|
-
|
|
297
|
-
## ⭐️ Show Your Support
|
|
298
|
-
|
|
299
|
-
If this project helped you, consider giving it a ⭐️!
|
|
300
|
-
|
|
301
|
-
Give a ⭐️ if this project helped you!
|
|
302
|
-
|
|
303
|
-
Or if you are brave enough consider [making a donation](https://github.com/sponsors/bartholomej) for some 🍺 or 🍵 ;)
|
|
304
|
-
|
|
305
|
-
## 🛡️ Privacy Policy
|
|
306
|
-
|
|
307
|
-
I DO NOT STORE ANY DATA. PERIOD.
|
|
308
|
-
|
|
309
|
-
I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.
|
|
310
|
-
|
|
311
|
-
That's why, with atlas obscura api, what happens on your device stays on your device till disappear.
|
|
312
|
-
|
|
313
|
-
## 📝 License
|
|
314
|
-
|
|
315
|
-
Copyright © 2025 [Lukas Bartak](http://bartweb.cz)
|
|
316
|
-
|
|
317
|
-
Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)
|
|
318
|
-
|
|
319
|
-
**This is unofficial, experimental, made for fun, and has nothing to do with Atlas Obscura ❤️ itself.**
|
|
320
|
-
|
|
321
|
-
All contents are licensed under the [MIT license].
|
|
322
|
-
|
|
323
|
-
[MIT license]: LICENSE
|
package/fetchers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetchPage: (url: string, headersCustom?: Headers) => Promise<string>;
|
package/fetchers/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fetchPage = void 0;
|
|
7
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
|
-
const USER_AGENTS = [
|
|
9
|
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0',
|
|
10
|
-
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0',
|
|
11
|
-
'Dalvik/2.1.0 (Linux; U; Android 8.1.0; C6L Build/OPM2.171019.012)',
|
|
12
|
-
'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',
|
|
13
|
-
'Mozilla/5.0 (Linux; Android 12; SM-A127F Build/SP1A.210812.016; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/96.0.4664.104 Mobile Safari/537.36 Instagram 243.0.0.16.111 Android (31/12; 300dpi; 720x1467; samsung; SM-A127F; a12s; exynos850; in_ID; 382290496)',
|
|
14
|
-
'Mozilla/5.0 (Linux; Android 11; M2101K7BNY Build/RP1A.200720.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.70 Mobile Safari/537.36 [FB_IAB/Orca-Android;FBAV/369.0.0.7.111;]'
|
|
15
|
-
];
|
|
16
|
-
const headers = {
|
|
17
|
-
'User-Agent': USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],
|
|
18
|
-
'Cache-Control': 'no-cache'
|
|
19
|
-
};
|
|
20
|
-
const fetchPage = async (url, headersCustom) => {
|
|
21
|
-
try {
|
|
22
|
-
const response = await (0, cross_fetch_1.default)(url, { headers: { ...headers, ...headersCustom }, credentials: 'omit' });
|
|
23
|
-
if (response.status >= 400 && response.status < 600) {
|
|
24
|
-
throw new Error(`atlas-obscura-api: Bad response ${response.status} for url: ${url}`);
|
|
25
|
-
}
|
|
26
|
-
return await response.text();
|
|
27
|
-
}
|
|
28
|
-
catch (e) {
|
|
29
|
-
console.error(e);
|
|
30
|
-
return 'Error';
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
exports.fetchPage = fetchPage;
|
package/interfaces/global.d.ts
DELETED
package/interfaces/global.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Coordinates } from './global.js';
|
|
2
|
-
export interface LocationResult {
|
|
3
|
-
total: Total;
|
|
4
|
-
per_page: number;
|
|
5
|
-
current_page: number;
|
|
6
|
-
location: string;
|
|
7
|
-
q: string;
|
|
8
|
-
coordinates: Coordinates;
|
|
9
|
-
results: Location[];
|
|
10
|
-
}
|
|
11
|
-
export interface Location {
|
|
12
|
-
title: string;
|
|
13
|
-
subtitle: string;
|
|
14
|
-
location: string;
|
|
15
|
-
thumbnail_url: string;
|
|
16
|
-
url: string;
|
|
17
|
-
id: number;
|
|
18
|
-
hide_from_maps?: string;
|
|
19
|
-
coordinates: Coordinates;
|
|
20
|
-
distance_from_query: string;
|
|
21
|
-
}
|
|
22
|
-
export interface Total {
|
|
23
|
-
value: number;
|
|
24
|
-
relation: string;
|
|
25
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Coordinates } from './global.js';
|
|
2
|
-
export interface PlaceShort {
|
|
3
|
-
id: number;
|
|
4
|
-
title: string;
|
|
5
|
-
subtitle: string;
|
|
6
|
-
city: string;
|
|
7
|
-
country: string;
|
|
8
|
-
location: string;
|
|
9
|
-
url: string;
|
|
10
|
-
hide_from_maps?: string;
|
|
11
|
-
physical_status: string;
|
|
12
|
-
thumbnail_url: string;
|
|
13
|
-
thumbnail_url_3x2: string;
|
|
14
|
-
coordinates: Coordinates;
|
|
15
|
-
nearby_places: PlaceShort[];
|
|
16
|
-
nearby_foods: PlaceShort[];
|
|
17
|
-
}
|
|
18
|
-
export interface PlaceExtend {
|
|
19
|
-
description?: string[];
|
|
20
|
-
tags?: Tag[];
|
|
21
|
-
directions?: string[];
|
|
22
|
-
imageCover?: string;
|
|
23
|
-
images?: string[];
|
|
24
|
-
}
|
|
25
|
-
export interface Tag {
|
|
26
|
-
title: string;
|
|
27
|
-
link: string;
|
|
28
|
-
}
|
|
29
|
-
export interface Place extends PlaceShort, PlaceExtend {
|
|
30
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Coordinates, FetchOptions } from './../interfaces/global.js';
|
|
2
|
-
import { LocationResult } from './../interfaces/locations.interface.js';
|
|
3
|
-
import { PlaceExtend, PlaceShort } from './../interfaces/placeId.interface.js';
|
|
4
|
-
import { PlacesAll } from './../interfaces/places-all.interface.js';
|
|
5
|
-
export declare class PlacesScraper {
|
|
6
|
-
placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
|
|
7
|
-
search(coords: Coordinates, page?: number, options?: FetchOptions): Promise<LocationResult>;
|
|
8
|
-
placeByIdShort(id: number, options?: FetchOptions): Promise<PlaceShort>;
|
|
9
|
-
placeFull(url: string, options?: FetchOptions): Promise<PlaceExtend>;
|
|
10
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlacesScraper = void 0;
|
|
4
|
-
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
-
const index_js_1 = require("../fetchers/index.js");
|
|
6
|
-
const utils_js_1 = require("../utils.js");
|
|
7
|
-
const vars_js_1 = require("../vars.js");
|
|
8
|
-
class PlacesScraper {
|
|
9
|
-
async placesAll(options) {
|
|
10
|
-
const response = await (0, index_js_1.fetchPage)(vars_js_1.URL_PLACES_ALL, options?.headers);
|
|
11
|
-
const html = (0, node_html_parser_1.parse)(response).innerHTML;
|
|
12
|
-
const data = html.match(/AtlasObscura\.all_places = (.*?);/);
|
|
13
|
-
return (0, utils_js_1.parseResults)(data);
|
|
14
|
-
}
|
|
15
|
-
async search(coords, page = 1, options) {
|
|
16
|
-
const url = (0, vars_js_1.urlSearch)(coords, page);
|
|
17
|
-
const response = await (0, index_js_1.fetchPage)(url, options?.headers);
|
|
18
|
-
const html = (0, node_html_parser_1.parse)(response).innerHTML;
|
|
19
|
-
const data = html.match(/AtlasObscura\.place_search = (.*?);/);
|
|
20
|
-
return (0, utils_js_1.parseResults)(data);
|
|
21
|
-
}
|
|
22
|
-
async placeByIdShort(id, options) {
|
|
23
|
-
const url = (0, vars_js_1.urlPlaceId)(id);
|
|
24
|
-
const data = await (0, index_js_1.fetchPage)(url, options?.headers);
|
|
25
|
-
let place = null;
|
|
26
|
-
try {
|
|
27
|
-
place = JSON.parse(data);
|
|
28
|
-
if (place && typeof place.hide_from_maps === 'string') {
|
|
29
|
-
place.hide_from_maps = place.hide_from_maps === 'true';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.error('Error parsing placeById', id);
|
|
34
|
-
}
|
|
35
|
-
return place;
|
|
36
|
-
}
|
|
37
|
-
async placeFull(url, options) {
|
|
38
|
-
const data = await (0, index_js_1.fetchPage)(url, options?.headers);
|
|
39
|
-
const html = (0, node_html_parser_1.parse)(data);
|
|
40
|
-
const descriptions = html.querySelectorAll('.place-body p').map((p) => p.innerHTML);
|
|
41
|
-
const sectionDirections = Array.from(html.querySelectorAll('section')).find((sec) => {
|
|
42
|
-
const h2 = sec.querySelector('h2');
|
|
43
|
-
return h2 && h2.textContent.trim() === 'Know Before You Go';
|
|
44
|
-
});
|
|
45
|
-
const directions = sectionDirections
|
|
46
|
-
? Array.from(sectionDirections.querySelectorAll('p')).map((p) => p.textContent.trim())
|
|
47
|
-
: [];
|
|
48
|
-
const tags = html.querySelectorAll('.aon-pill-badge-component').map((x) => {
|
|
49
|
-
return {
|
|
50
|
-
title: x.querySelector('.aon-pill-badge-text')?.innerHTML.trim(),
|
|
51
|
-
link: x.attributes.href
|
|
52
|
-
};
|
|
53
|
-
});
|
|
54
|
-
const slides = html.querySelectorAll('.swiper-slide');
|
|
55
|
-
const images = Array.from(slides)
|
|
56
|
-
.map((slide) => {
|
|
57
|
-
const img = slide.querySelector('img');
|
|
58
|
-
return img ? img.getAttribute('src') : null;
|
|
59
|
-
})
|
|
60
|
-
.filter(Boolean);
|
|
61
|
-
const imageCover = images[0];
|
|
62
|
-
return { description: descriptions, directions, tags, imageCover, images };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.PlacesScraper = PlacesScraper;
|
package/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const parseResults: <T>(matches: RegExpMatchArray) => T;
|
package/utils.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseResults = void 0;
|
|
4
|
-
const parseResults = (matches) => {
|
|
5
|
-
let locations = null;
|
|
6
|
-
if (matches && matches[1]?.length) {
|
|
7
|
-
try {
|
|
8
|
-
locations = JSON.parse(matches[1]);
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
console.error('Error parsing all places');
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return locations;
|
|
15
|
-
};
|
|
16
|
-
exports.parseResults = parseResults;
|
package/vars.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const URL_PLACES_ALL = "https://www.atlasobscura.com/articles/all-places-in-the-atlas-on-one-map";
|
|
2
|
-
export declare const urlSearch: (coord: {
|
|
3
|
-
lat: number;
|
|
4
|
-
lng: number;
|
|
5
|
-
}, page?: number) => string;
|
|
6
|
-
export declare const urlPlaceId: (id: number) => string;
|
package/vars.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.urlPlaceId = exports.urlSearch = exports.URL_PLACES_ALL = void 0;
|
|
4
|
-
exports.URL_PLACES_ALL = 'https://www.atlasobscura.com/articles/all-places-in-the-atlas-on-one-map';
|
|
5
|
-
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 : ''}`;
|
|
6
|
-
exports.urlSearch = urlSearch;
|
|
7
|
-
const urlPlaceId = (id) => `https://www.atlasobscura.com/places/${id}.json?place_only=1`;
|
|
8
|
-
exports.urlPlaceId = urlPlaceId;
|