-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeta-language-basic-settings-tables-normalization.html
391 lines (360 loc) · 17.6 KB
/
meta-language-basic-settings-tables-normalization.html
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Diggernaut: Documentation for Meta-Language | Basic Settings | Tables Normalization</title>
<meta name="description" content="Tables normalization makes scraping process easier, scraper's logic becomes more simple.">
<meta name="keywords" content="Diggernaut, scraping, web scraping, scraper, web scraper, meta-language, make scraper, scraper for websites, learning to scrape, data acquisition, create scraper, online scraper, content scraper, scraper for shop, scraper for classifieds, coding scraper, selenium">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Alternatives -->
<link rel="canonical" href="https://www.diggernaut.com/dev/meta-language-basic-settings-tables-normalization.html"/>
<link rel="alternate" hreflang="en" href="https://www.diggernaut.com/dev/meta-language-basic-settings-tables-normalization.html"/>
<link rel="alternate" hreflang="ru" href="https://www.diggernaut.ru/dev/meta-yazyk-bazovye-nastroyki-normalizaciya-tablits.html"/>
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@diggernautcom">
<meta name="twitter:site" content="@diggernautcom">
<meta name="twitter:title" content="Diggernaut: Documentation for Meta-Language | Basic Settings | Tables Normalization">
<meta name="twitter:image" content="https://www.diggernaut.com/static/dev/images/og_img_devml_en.png">
<!-- OG -->
<meta property="og:locale" content="en_US"/>
<meta property="og:site_name" content="Diggernaut"/>
<meta property="og:title" content="Diggernaut: Documentation for Meta-Language | Basic Settings | Tables Normalization"/>
<meta property="og:url" content="https://www.diggernaut.com/dev/meta-language-basic-settings-tables-normalization.html"/>
<meta property="og:type" content="website"/>
<meta property="og:description" content="Tables normalization makes scraping process easier, scraper's logic becomes more simple."/>
<meta property="og:image" content="https://www.diggernaut.com/static/dev/images/og_img_devml_en.png"/>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="css/flexboxgrid.min.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/ml-style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/prism.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/font-awesome.min.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/gsce.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<script>
(function () {
var cx = '017044341280497706869:0g3mtgyp2is';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
</head>
<body>
<header>
<nav class="teal darken-1" role="navigation" id="menu">
<div class="container-gcse">
<gcse:search></gcse:search>
</div>
</nav>
</header>
<main>
<div class="lessons-container" id="main">
<div class="container">
<h1>Basic Settings</h1>
<div>
<h2>Tables Normalization</h2>
<p class="flow-text">
Probably you already met such tables, in which multiple cells or rows are combined into single cell.
It makes the table more readable for humans and less readable for computer. This effect is achieved by using such attributes as
<span class = "hlt2">rowspan</span> and <span class = "hlt2">colspan</span> and makes it very difficult to write a common logic for
passing all rows of such table.
</p>
<p class="flow-text">
To simplify this task, we introduced a special parameter <span class = "hlt2">normalize_tables</span>. When you use it,
engine will automatically split all merged cells and same content will be used for all splitted cells. After it you can build logic
to pass through stable table structure, and it will be much easier to do as you can use same logic for each row.
</p>
<p class="flow-text">
Sample of using tables normalization mechanism:
</p>
<div class="row">
<div class="col s12">
<ul class="tabs excdark">
<li class="tab col s4"><a class="active" href="#config">Digger configuration</a></li>
<li class="tab col s4"><a href="#html">Source HTML</a></li>
<li class="tab col s4"><a href="#log">Execution Log</a></li>
</ul>
</div>
<div id="config" class="col s12">
<pre class="language-yaml">
<code class="language-yaml">---
config:
debug: 2
agent: Firefox
# TURNING ON AUTOMATED TABLES NORMALIZATION
normalize_tables: yes
do:
- walk:
to: https://www.diggernaut.com/sandbox/meta-lang-normalize-tables-en.html
do:
- find:
path: '#table-1'
do:
- find:
path: '#table-2'
do:
</code></pre>
</div>
<div id="html" class="col s12">
<pre class="language-html">
<code class="language-html"><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Diggernaut | Meta-language | Normalize tables sample</title>
</head>
<body>
<table id="table-1" width="200" border="1" cellpadding="4" cellspacing="0">
<tr>
<td rowspan="2" bgcolor="#FBF0DB">Cell 1</td>
<td>Cell 2</td>
</tr>
<tr>
<td>Cell 3</td>
</tr>
</table>
<br/>
<table id="table-2" width="200" border="1" cellpadding="4" cellspacing="0">
<tr>
<td colspan="2" bgcolor="#FBF0DB">Cell 1</td>
</tr>
<tr>
<td>Cell 2</td>
<td>Cell 3</td>
</tr>
</table>
</body>
</html>
</code></pre>
</div>
<div id="log" class="col s12">
<table id="datatable_logs" class="striped responsive-table debug-log" role="grid" aria-describedby="datatable_logs_info">
<thead>
<tr role="row">
<th class="sorting_desc" tabindex="0" aria-controls="datatable_logs" rowspan="1" colspan="1" aria-label="Time: activate to sort column ascending" aria-sort="descending" width="11%">Time</th>
<th class="sorting" tabindex="0" aria-controls="datatable_logs" rowspan="1" colspan="1" aria-label="Level: activate to sort column ascending" width="4%">Level</th>
<th class="word-wrapper sorting_disabled" rowspan="1" colspan="1" aria-label="Message">Message</th>
</tr>
</thead>
<tbody>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:53:843</td>
<td>info</td>
<td class=" word-wrapper">Scrape is done</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">2017-10-22 22:53:53:836</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Block content:
<tbody><br/>
<tr><br/>
<span class="hlt2"><td colspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"><td colspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
</tr>
<tr><br/>
<span class="hlt2"><td>Cell 2</td></span><br/>
<span class="hlt2"><td>Cell 3</td></span><br/>
</tr><br/>
</tbody>
</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:53:828</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Number of found blocks: 1</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">2017-10-22 22:53:53:821</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Looking for: #table-2</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:53:814</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Block content:
<tbody><br/>
<tr><br/>
<span class="hlt2"><td rowspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"><td>Cell 2</td></span><br/>
</tr><br/>
<tr><br/>
<span class="hlt2"><td rowspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"><td>Cell 3</td></span><br/>
</tr><br/>
</tbody>
</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">2017-10-22 22:53:53:808</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Number of found blocks: 1</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:53:801</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Looking for: #table-1</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">2017-10-22 22:53:53:790</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Page content: <!DOCTYPE html><br/>
<html lang="en"><br/>
<head><br/>
<meta charset="UTF-8"/><br/>
<title>Diggernaut | Meta-language | Normalize tables sample</title><br/>
</head><br/>
<body><br/>
<span class="hlt2"><table id="table-1" width="200" border="1" cellpadding="4" cellspacing="0"></span><br/>
<span class="hlt2"><tbody></span><br/>
<span class="hlt2"><tr></span><br/>
<span class="hlt2"><td rowspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"><td>Cell 2</td></span><br/>
<span class="hlt2"></tr></span><br/>
<span class="hlt2"><tr></span><br/>
<span class="hlt2"><td rowspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"><td>Cell 3</td></span><br/>
<span class="hlt2"></tr></span><br/>
<span class="hlt2"></tbody></span><br/>
<span class="hlt2"></table></span><br/>
<br/><br/>
<span class="hlt2"><table id="table-2" width="200" border="1" cellpadding="4" cellspacing="0"></span><br/>
<span class="hlt2"><tbody></span><br/>
<span class="hlt2"><tr></span><br/>
<span class="hlt2"><td colspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"><td colspan="1" bgcolor="#FBF0DB">Cell 1</td></span><br/>
<span class="hlt2"></tr></span><br/>
<span class="hlt2"><tr></span><br/>
<span class="hlt2"><td>Cell 2</td></span><br/>
<span class="hlt2"><td>Cell 3</td></span><br/>
<span class="hlt2"></tr></span><br/>
<span class="hlt2"></tbody></span><br/>
<span class="hlt2"></table></span><br/>
</body><br/>
</html></td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:52:945</td>
<td>info</td>
<td class=" word-wrapper">Retrieving page (GET): https://www.diggernaut.com/sandbox/meta-lang-normalize-tables-en.html</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">2017-10-22 22:53:52:937</td>
<td>info</td>
<td class=" word-wrapper">Starting scrape</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:52:920</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Setting up default proxy</td>
</tr>
<tr role="row" class="even">
<td class="sorting_1">2017-10-22 22:53:52:906</td>
<td><span class="log-debug">debug</span></td>
<td class=" word-wrapper">Setting up surf</td>
</tr>
<tr role="row" class="odd">
<td class="sorting_1">2017-10-22 22:53:52:880</td>
<td>info</td>
<td class=" word-wrapper">Starting digger: meta-lang-normalize-tables [1857]</td>
</tr>
</tbody>
</table>
</div>
</div>
<span class="spacer"></span>
<blockquote class="warning darken-1">
<p class="flow-text">
By default tables normalization is <strong>turned off</strong>.
</p>
</blockquote>
<blockquote class="warning darken-1">
<p class="flow-text">
<strong> Please pay attention!</strong> <br/>
To enable the option, you must put <span class = "hlt2">yes</span> value without quotes.
</p>
</blockquote>
<div class="row">
<div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
<div class="pagination">
<a href="meta-language-iterators-introduction.html" class="btn goto teal z-depth-2">Next</a>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<footer class="page-footer teal darken-1">
<div class="container">
<div class="row">
<div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
<div class="social">
<a class="btn btn-floating btn-flat" href="https://www.diggernaut.com/blog/category/learning-meta-language/"
target="_blank"><i class="fa fa-wordpress"></i></a>
<a class="btn btn-floating btn-flat" href="https://vk.com/diggernaut" target="_blank"><i class="fa fa-vk"></i></a>
<a class="btn btn-floating btn-flat" href="https://www.facebook.com/diggernaut/" target="_blank"><i class="fa fa-facebook"></i></a>
<a class="btn btn-floating btn-flat" href="https://www.linkedin.com/company/10908957/" target="_blank"><i class="fa fa-linkedin"></i></a>
<a class="btn btn-floating btn-flat" href="https://twitter.com/diggernautcom" target="_blank"><i class="fa fa-twitter"></i></a>
</div>
</div>
</div>
</div>
</footer>
<!-- Scripts-->
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/materialize.min.js"></script>
<script src="js/prism.js"></script>
<script src="js/meta-language-init.js"></script>
<!-- Google analytics -->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-80717561-1', 'auto');
ga('send', 'pageview');
</script>
<!-- /Google analytics -->
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w.yaCounter47560513 = new Ya.Metrika({
id:47560513,
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
} catch(e) { }
});
var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = "https://mc.yandex.ru/metrika/watch.js";
if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/47560513" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
</body>
</html>