forked from omkarcloud/google-maps-scraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_more_data.js
374 lines (293 loc) · 6.76 KB
/
get_more_data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
function parse() {
let inputString = window.APP_INITIALIZATION_STATE[3][6]
let substringToRemove = ")]}'"
let modifiedString
if (inputString.startsWith(substringToRemove)) {
modifiedString = inputString.slice(substringToRemove.length)
} else {
}
return JSON.parse(modifiedString)
}
function get_description(data) {
return data?.[6]?.[32]?.[1]?.[1]
}
function get_open_state(data) {
return data?.[6]?.[34]?.[4]?.[4]
}
function get_plus_code(data) {
return data?.[6]?.[183]?.[2]?.[2]?.[0]
}
function get_gps_coordinates(data) {
return { latitude: data?.[6]?.[9]?.[2], longitude: data?.[6]?.[9]?.[3] }
}
function get_images(data) {
let images = data?.[6]?.[171]?.[0] ?? []
const ls = []
for (let index = 0; index < images.length; index++) {
const element = images[index]
const title = element[2]
const thumbnail = element[3]?.[0]?.[6]?.[0]
if (thumbnail) {
const result = {
title: title,
thumbnail: thumbnail,
}
ls.push(result)
}
}
return ls
}
function get_reservations(data) {
let images = data?.[6]?.[46] ?? []
const ls = []
for (let index = 0; index < images.length; index++) {
const element = images[index]
const link = element[0]
const source = element[1]
const result = {
link,
source,
}
ls.push(result)
}
return ls
}
function get_order_online_link(data) {
let images =
data?.[6]?.[75]?.[0]?.[1]?.[2] ?? data?.[6]?.[75]?.[0]?.[0]?.[2] ?? []
const ls = []
for (let index = 0; index < images.length; index++) {
const element = images[index]
const source = element[0][0]
const link = element[1][2][0]
const result = {
link,
source,
}
ls.push(result)
}
return ls
}
function get_hours(data) {
let images = data?.[6]?.[34]?.[1] ?? []
const ls = []
for (let index = 0; index < images.length; index++) {
const element = images[index]
const day = element[0]
const times = element[1]
const result = {
day,
times,
}
ls.push(result)
}
return ls
}
function get_options(data) {
return data.map((x) => {
const enabled = x[2]?.[1]?.[0]?.[0] ?? x[4]?.[0]
return {
name: x[1],
enabled: enabled != 0,
}
})
}
function get_about(data) {
let rvs = data?.[6]?.[100]?.[1] ?? []
const ls = []
for (let index = 0; index < rvs.length; index++) {
const element = rvs[index]
const id = element[0]
const name = element[1]
const options = get_options(element[2] ?? [])
const result = {
id,
name,
options,
}
ls.push(result)
}
return ls
}
function get_menu(data) {
const link = data?.[6]?.[38]?.[0]
const source = data?.[6]?.[38]?.[1]
const result = {
link,
source,
}
return result
}
function get_review_images(data) {
return data.map((x) => x[6][0])
}
function get_user_reviews(data) {
let rvs = data?.[6]?.[52]?.[0] ?? []
const ls = []
for (let index = 0; index < rvs.length; index++) {
const element = rvs[index]
const name = element[0][1]
const profile_picture = element[0][2]
const when = element[1]
const rating = element[4]
const description = element[3]
const images = get_review_images(element[14] ?? [])
const result = {
name,
profile_picture,
rating,
description,
images,
when,
}
ls.push(result)
}
return ls
}
function get_owner(data) {
const name = data?.[6]?.[57]?.[1]
const id = data?.[6]?.[57]?.[2]
const link = "https://www.google.com/maps/contrib/" + id
if (!id) {
return {
name,
}
}
const result = {
id,
name,
link,
}
return result
}
function get_complete_address(data) {
const borough = data?.[6]?.[183]?.[1]?.[0]
const street = data?.[6]?.[183]?.[1]?.[1]
const city = data?.[6]?.[183]?.[1]?.[3]
const postal_code = data?.[6]?.[183]?.[1]?.[4]
const state = data?.[6]?.[183]?.[1]?.[5]
const country_code = data?.[6]?.[183]?.[1]?.[6]
const result = {
borough,
street,
city,
postal_code,
state,
country_code,
}
return result
}
function get_time_zone(data) {
return data?.[6]?.[30]
}
function get_reviews_link(data) {
return data?.[6]?.[4]?.[3]?.[0]
}
function get_rating(data) {
return data?.[6]?.[4]?.[7]
}
function get_reviews(data) {
return data?.[6]?.[4]?.[8]
}
function get_phone(data) {
return data?.[6]?.[178]?.[0]?.[0]
}
function get_price_range(data) {
return data?.[6]?.[4]?.[2]
}
function get_title(data) {
return data?.[6]?.[11]
}
function get_address(data) {
return data?.[6]?.[18]
}
function get_website(data) {
return data?.[6]?.[7]?.[0]
}
function get_main_category(data) {
return data?.[6]?.[13]?.[0]
}
function get_cid(data) {
return data?.[25]?.[3]?.[0]?.[13]?.[0]?.[0]?.[1]
}
function get_data_id(data) {
return data?.[6]?.[10]
}
function get_reviews_per_rating(data) {
return {
1: data?.[6]?.[52]?.[3]?.[0],
2: data?.[6]?.[52]?.[3]?.[1],
3: data?.[6]?.[52]?.[3]?.[2],
4: data?.[6]?.[52]?.[3]?.[3],
5: data?.[6]?.[52]?.[3]?.[4],
}
}
function get_more_data() {
let data = parse()
let categories = get_categories(data)
let place_id = get_place_id(data)
let order_online_links = get_order_online_link(data)
let thumbnail = get_thumbnail(data)
let coordinates = get_gps_coordinates(data)
let images = get_images(data)
let description = get_description(data)
let status = get_open_state(data)
let plus_code = get_plus_code(data)
let reservations = get_reservations(data)
let menu = get_menu(data)
let owner = get_owner(data)
let time_zone = get_time_zone(data)
let complete_address = get_complete_address(data)
let reviews_link = get_reviews_link(data)
let price_range = get_price_range(data)
let reviews_per_rating = get_reviews_per_rating(data)
let cid = get_cid(data)
let data_id = get_data_id(data)
let about = get_about(data)
let hours = get_hours(data)
let rating = get_rating(data)
let reviews = get_reviews(data)
let phone = get_phone(data)
let title = get_title(data)
let address = get_address(data)
let website = get_website(data)
let main_category = get_main_category(data)
let user_reviews = get_user_reviews(data)
// Add more
// skipped questions_and_answers
// popular_times
// peolple also search for
return {
place_id,
title,
rating,
reviews,
status,
price_range,
website,
phone,
description,
address,
reviews_per_rating,
reviews_link,
thumbnail,
images,
hours,
menu,
order_online_links,
reservations,
owner,
main_category,
categories,
coordinates,
plus_code,
complete_address,
time_zone,
about,
user_reviews,
cid,
data_id,
}
}
// console.log(get_more_data())
return get_more_data()