atlas-obscura-api 3.1.0 → 3.2.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/fetchers/index.js +4 -8
- package/index.d.ts +5 -5
- package/index.js +2 -2
- package/interfaces/locations.interface.d.ts +1 -1
- package/interfaces/placeId.interface.d.ts +1 -1
- package/interfaces/places-all.interface.d.ts +1 -1
- package/package.json +5 -4
- package/services/location.service.d.ts +4 -4
- package/services/location.service.js +11 -11
package/fetchers/index.js
CHANGED
|
@@ -6,16 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.fetchPage = void 0;
|
|
7
7
|
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
8
8
|
const USER_AGENTS = [
|
|
9
|
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
|
10
|
-
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1',
|
|
11
|
-
'Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36',
|
|
12
|
-
'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36',
|
|
13
|
-
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15',
|
|
14
9
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0',
|
|
15
|
-
'Mozilla/5.0 (iPad; CPU OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1',
|
|
16
|
-
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
|
17
10
|
'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0',
|
|
18
|
-
'
|
|
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;]'
|
|
19
15
|
];
|
|
20
16
|
const headers = {
|
|
21
17
|
'User-Agent': USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)],
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Coordinates, FetchOptions } from 'interfaces/global';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { PlacesScraper } from './services/location.service';
|
|
1
|
+
import { Coordinates, FetchOptions } from './interfaces/global.js';
|
|
2
|
+
import { LocationResult } from './interfaces/locations.interface.js';
|
|
3
|
+
import { Place, PlaceShort } from './interfaces/placeId.interface.js';
|
|
4
|
+
import { PlacesAll } from './interfaces/places-all.interface.js';
|
|
5
|
+
import { PlacesScraper } from './services/location.service.js';
|
|
6
6
|
export declare class AtlasObscura {
|
|
7
7
|
private locationService;
|
|
8
8
|
constructor(locationService: PlacesScraper);
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.atlasobscura = exports.AtlasObscura = void 0;
|
|
4
|
-
const
|
|
4
|
+
const location_service_js_1 = require("./services/location.service.js");
|
|
5
5
|
class AtlasObscura {
|
|
6
6
|
locationService;
|
|
7
7
|
constructor(locationService) {
|
|
@@ -23,5 +23,5 @@ class AtlasObscura {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.AtlasObscura = AtlasObscura;
|
|
26
|
-
const locationScraper = new
|
|
26
|
+
const locationScraper = new location_service_js_1.PlacesScraper();
|
|
27
27
|
exports.atlasobscura = new AtlasObscura(locationScraper);
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atlas-obscura-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Atlas Obscura API in JavaScript. NPM library for scrapping atlasobscura.com",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"author": "BART! <bart@bartweb.cz>",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "tsc -w",
|
|
9
9
|
"prebuild": "rimraf dist",
|
|
10
|
-
"build": "tsc",
|
|
11
|
-
"postbuild": "npm-prepare-dist -s postinstall -s prepare",
|
|
10
|
+
"build": "tsc && npm-prepare-dist -s postinstall -s prepare",
|
|
12
11
|
"tsc": "tsc",
|
|
13
12
|
"demo": "tsx demo",
|
|
14
13
|
"lint": "eslint ./src/**/**/* --fix",
|
|
15
14
|
"test": "vitest",
|
|
15
|
+
"test:coverage": "yarn test run --coverage",
|
|
16
16
|
"publish:next": "yarn && yarn build && yarn test --coverage && npm publish --folder dist --tag beta",
|
|
17
17
|
"postversion": "git push && git push --follow-tags",
|
|
18
18
|
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"cross-fetch": "^4.
|
|
25
|
+
"cross-fetch": "^4.1.0",
|
|
26
26
|
"node-html-parser": "^7.0.1"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"lint-staged": {
|
|
53
53
|
"*.ts": "eslint --cache --fix"
|
|
54
54
|
},
|
|
55
|
+
"packageManager": "yarn@4.10.3",
|
|
55
56
|
"module": "./index.js",
|
|
56
57
|
"types": "./index.d.ts"
|
|
57
58
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Coordinates, FetchOptions } from 'interfaces/global';
|
|
2
|
-
import { LocationResult } from 'interfaces/locations.interface';
|
|
3
|
-
import { PlaceExtend, PlaceShort } from 'interfaces/placeId.interface';
|
|
4
|
-
import { PlacesAll } from 'interfaces/places-all.interface';
|
|
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
5
|
export declare class PlacesScraper {
|
|
6
6
|
placesAll(options?: FetchOptions): Promise<PlacesAll[]>;
|
|
7
7
|
search(coords: Coordinates, page?: number, options?: FetchOptions): Promise<LocationResult>;
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PlacesScraper = void 0;
|
|
4
4
|
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
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
8
|
class PlacesScraper {
|
|
9
9
|
async placesAll(options) {
|
|
10
|
-
const response = await (0,
|
|
10
|
+
const response = await (0, index_js_1.fetchPage)(vars_js_1.URL_PLACES_ALL, options?.headers);
|
|
11
11
|
const html = (0, node_html_parser_1.parse)(response).innerHTML;
|
|
12
12
|
const data = html.match(/AtlasObscura\.all_places = (.*?);/);
|
|
13
|
-
return (0,
|
|
13
|
+
return (0, utils_js_1.parseResults)(data);
|
|
14
14
|
}
|
|
15
15
|
async search(coords, page = 1, options) {
|
|
16
|
-
const url = (0,
|
|
17
|
-
const response = await (0,
|
|
16
|
+
const url = (0, vars_js_1.urlSearch)(coords, page);
|
|
17
|
+
const response = await (0, index_js_1.fetchPage)(url, options?.headers);
|
|
18
18
|
const html = (0, node_html_parser_1.parse)(response).innerHTML;
|
|
19
19
|
const data = html.match(/AtlasObscura\.place_search = (.*?);/);
|
|
20
|
-
return (0,
|
|
20
|
+
return (0, utils_js_1.parseResults)(data);
|
|
21
21
|
}
|
|
22
22
|
async placeByIdShort(id, options) {
|
|
23
|
-
const url = (0,
|
|
24
|
-
const data = await (0,
|
|
23
|
+
const url = (0, vars_js_1.urlPlaceId)(id);
|
|
24
|
+
const data = await (0, index_js_1.fetchPage)(url, options?.headers);
|
|
25
25
|
let place = null;
|
|
26
26
|
try {
|
|
27
27
|
place = JSON.parse(data);
|
|
@@ -35,7 +35,7 @@ class PlacesScraper {
|
|
|
35
35
|
return place;
|
|
36
36
|
}
|
|
37
37
|
async placeFull(url, options) {
|
|
38
|
-
const data = await (0,
|
|
38
|
+
const data = await (0, index_js_1.fetchPage)(url, options?.headers);
|
|
39
39
|
const html = (0, node_html_parser_1.parse)(data);
|
|
40
40
|
const descriptions = html.querySelectorAll('.place-body p').map((p) => p.innerHTML);
|
|
41
41
|
const sectionDirections = Array.from(html.querySelectorAll('section')).find((sec) => {
|