Please let me know if there is any option available to scrape data inside a JavaScript function below using Selenium
page https://www.bayut.com/index/sale-prices-apartments-abu-dhabi.html
input code
JavaScript
x
296
296
1
<script type="text/javascript">
2
3
var chartData1 = [];
4
var chartData2 = [];
5
var chartData3 = [];
6
7
function generateChartData() {
8
var newDate = new Date('2010-01-31');
9
chartData1.push({
10
date: newDate,
11
value: 1443,
12
disply_val: '1,443'
13
});
14
chartData2.push({
15
date: newDate,
16
value: 0,
17
disply_val: '0'
18
});
19
chartData3.push({
20
date: newDate,
21
value: 100.0000,
22
disply_val: '100'
23
});
24
var newDate = new Date('2010-02-28');
25
chartData1.push({
26
date: newDate,
27
value: 1407,
28
disply_val: '1,407'
29
});
30
chartData2.push({
31
date: newDate,
32
value: 0,
33
disply_val: '0'
34
});
35
chartData3.push({
36
date: newDate,
37
value: 97.5000,
38
disply_val: '98'
39
});
40
var newDate = new Date('2010-03-31');
41
chartData1.push({
42
date: newDate,
43
value: 1400,
44
disply_val: '1,400'
45
});
46
chartData2.push({
47
date: newDate,
48
value: 0,
49
disply_val: '0'
50
});
51
chartData3.push({
52
date: newDate,
53
value: 97.0000,
54
disply_val: '97'
55
});
56
var newDate = new Date('2010-04-30');
57
chartData1.push({
58
date: newDate,
59
value: 1433,
60
disply_val: '1,433'
61
});
62
chartData2.push({
63
date: newDate,
64
value: 0,
65
disply_val: '0'
66
});
67
chartData3.push({
68
date: newDate,
69
value: 99.3300,
70
disply_val: '99'
71
});
72
var newDate = new Date('2010-05-31');
73
chartData1.push({
74
date: newDate,
75
value: 1409,
76
disply_val: '1,409'
77
});
78
chartData2.push({
79
date: newDate,
80
value: 0,
81
disply_val: '0'
82
});
83
chartData3.push({
84
date: newDate,
85
value: 97.6700,
86
disply_val: '98'
87
});
88
var newDate = new Date('2010-06-30');
89
chartData1.push({
90
date: newDate,
91
value: 1380,
92
disply_val: '1,380'
93
});
94
chartData2.push({
95
date: newDate,
96
value: 0,
97
disply_val: '0'
98
});
99
chartData3.push({
100
date: newDate,
101
value: 95.6700,
102
disply_val: '96'
103
});
104
var newDate = new Date('2010-07-31');
105
chartData1.push({
106
date: newDate,
107
value: 1270,
108
disply_val: '1,270'
109
});
110
chartData2.push({
111
date: newDate,
112
value: 0,
113
disply_val: '0'
114
});
115
chartData3.push({
116
date: newDate,
117
value: 88.0000,
118
disply_val: '88'
119
});
120
var newDate = new Date('2010-08-31');
121
chartData1.push({
122
date: newDate,
123
value: 1265,
124
disply_val: '1,265'
125
});
126
chartData2.push({
127
date: newDate,
128
value: 0,
129
disply_val: '0'
130
});
131
chartData3.push({
132
date: newDate,
133
value: 87.6700,
134
disply_val: '88'
135
});
136
var newDate = new Date('2010-09-30');
137
chartData1.push({
138
date: newDate,
139
value: 1251,
140
disply_val: '1,251'
141
});
142
chartData2.push({
143
date: newDate,
144
value: 0,
145
disply_val: '0'
146
});
147
chartData3.push({
148
date: newDate,
149
value: 86.6700,
150
disply_val: '87'
151
});
152
var newDate = new Date('2010-10-31');
153
chartData1.push({
154
date: newDate,
155
value: 1251,
156
disply_val: '1,251'
157
});
158
chartData2.push({
159
date: newDate,
160
value: 0,
161
disply_val: '0'
162
});
163
chartData3.push({
164
date: newDate,
165
value: 86.6700,
166
disply_val: '87'
167
});
168
var newDate = new Date('2010-11-30');
169
chartData1.push({
170
date: newDate,
171
value: 1227,
172
disply_val: '1,227'
173
});
174
chartData2.push({
175
date: newDate,
176
value: 0,
177
disply_val: '0'
178
});
179
chartData3.push({
180
date: newDate,
181
value: 85.0000,
182
disply_val: '85'
183
});
184
var newDate = new Date('2010-12-31');
185
chartData1.push({
186
date: newDate,
187
value: 1284,
188
disply_val: '1,284'
189
});
190
chartData2.push({
191
date: newDate,
192
value: 0,
193
disply_val: '0'
194
});
195
chartData3.push({
196
date: newDate,
197
value: 89.0000,
198
disply_val: '89'
199
});
200
var newDate = new Date('2011-01-31');
201
chartData1.push({
202
date: newDate,
203
value: 1284,
204
disply_val: '1,284'
205
});
206
chartData2.push({
207
date: newDate,
208
value: 0,
209
disply_val: '0'
210
});
211
chartData3.push({
212
date: newDate,
213
value: 89.0000,
214
disply_val: '89'
215
});
216
var newDate = new Date('2011-02-28');
217
chartData1.push({
218
date: newDate,
219
value: 1279,
220
disply_val: '1,279'
221
});
222
chartData2.push({
223
date: newDate,
224
value: 0,
225
disply_val: '0'
226
});
227
chartData3.push({
228
date: newDate,
229
value: 88.6700,
230
disply_val: '89'
231
});
232
var newDate = new Date('2011-03-31');
233
chartData1.push({
234
date: newDate,
235
value: 1212,
236
disply_val: '1,212'
237
});
238
chartData2.push({
239
date: newDate,
240
value: 0,
241
disply_val: '0'
242
});
243
chartData3.push({
244
date: newDate,
245
value: 84.0000,
246
disply_val: '84'
247
});
248
var newDate = new Date('2011-04-30');
249
chartData1.push({
250
date: newDate,
251
value: 1231,
252
disply_val: '1,231'
253
});
254
chartData2.push({
255
date: newDate,
256
value: 0,
257
disply_val: '0'
258
});
259
chartData3.push({
260
date: newDate,
261
value: 85.3300,
262
disply_val: '85'
263
});
264
var newDate = new Date('2011-05-31');
265
chartData1.push({
266
date: newDate,
267
value: 1279,
268
disply_val: '1,279'
269
});
270
chartData2.push({
271
date: newDate,
272
value: 0,
273
disply_val: '0'
274
});
275
chartData3.push({
276
date: newDate,
277
value: 88.6700,
278
disply_val: '89'
279
});
280
var newDate = new Date('2011-06-30');
281
chartData1.push({
282
date: newDate,
283
value: 1318,
284
disply_val: '1,318'
285
});
286
chartData2.push({
287
date: newDate,
288
value: 0,
289
disply_val: '0'
290
});
291
chartData3.push({
292
date: newDate,
293
value: 91.3300,
294
disply_val: '91'
295
});
296
Output
Date Value
2010-01-31 1443
2010-02-28 1407
Tried but not working My output file should have date and value columns, please let me know if there is option available
JavaScript
1
4
1
driver.find_element_by_id('newDate')
2
driver.find_elements_by_xpath("//*[@class=' mask_search']")
3
4
Advertisement
Answer
use driver.execute_script:
JavaScript
1
2
1
data = driver.execute_script('return [chartData1, chartData2, chartData3]')
2