-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeta-language-runtime-entities-arguments.html
247 lines (225 loc) · 10.2 KB
/
meta-language-runtime-entities-arguments.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Diggernaut: Documentation for Meta-Language | Runtime Entities | Arguments</title>
<meta name="description" content="Where do the arguments come from, how can you utilize them.">
<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, argumwents">
<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-runtime-entities-arguments.html"/>
<link rel="alternate" hreflang="en" href="https://www.diggernaut.com/dev/meta-language-runtime-entities-arguments.html"/>
<link rel="alternate" hreflang="ru" href="https://www.diggernaut.ru/dev/meta-yazyk-obyekty-sredy-vypolneniya-argumenty.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 | Runtime Entities | Arguments">
<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 | Runtime Entities | Arguments"/>
<meta property="og:url" content="https://www.diggernaut.com/dev/meta-language-runtime-entities-arguments.html"/>
<meta property="og:type" content="website"/>
<meta property="og:description" content="Where do the arguments come from, how can you utilize them."/>
<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>Runtime Entities</h1>
<div>
<h2>Arguments</h2>
<p class="flow-text">
Arguments, same as variables, are very widely used to substitute data, and can be used in the same cases,
as variables.
</p>
<p class="flow-text">
The main differences from the variables:
</p>
<blockquote class="custom darken-1">
<ol class="flow-text">
<li>Arguments are static data set by the <a href="meta-language-iterators-introduction.html">iterator</a> on a specific step of iteration loop</li>
<li>Arguments exist in all contexts and are context-independent</li>
<li>Arguments values can not be changed, but you can use them for substitution and read their values to the register</li>
</ol>
</blockquote>
<p class="flow-text">
Below are examples of using arguments in different situations:
</p>
<div class="row">
<div class="col s12">
<ul class="tabs excdark">
<li class="tab col s4"><a class="active" href="#arguments_url">Arguments in URL and CSS-Path</a></li>
<li class="tab col s4"><a href="#arguments_form">Arguments in a form</a></li>
<li class="tab col s4"><a href="#arguments_reg">Arguments in the register</a></li>
<li class="tab col s4"><a href="#arguments_js">Arguments in JS</a></li>
</ul>
</div>
<div id="arguments_url" class="col s12">
<pre class="language-yaml">
<code class="language-yaml"># USING ARGUMENTS `start_date` AND `end_date` OF DATES ITERATOR WHEN WE ARE LOADING SPECIFIC PAGE
- walk:
to: 'http://www.somesite.com/?getDataFrom=<%start_date%>&to=<%end_date%>'
do:
# USING ARGUMENT `age` OF CSV/FIELDSET ITERATOR IN THE COMMAND FOR ADDING LINK TO THE POOL
- link_add:
url: 'http://www.somesite.com/?getDataFromAge=<%age%>'
# USING ARGUMENT `date` IN THE COMMAND FOR FINDING ELEMENTS USING CSS-PATH
- find:
path: '.vetrina > tbody > tr:has(td:nth-of-type(4):matches(<%date%>))'
do:
</code></pre>
</div>
<div id="arguments_form" class="col s12">
<pre class="language-yaml">
<code class="language-yaml"># USING ARGUMENTS `start_date` AND `end_date` OF DATES ITERATOR IN POST REQUEST
- walk:
to:
post: http://www.somesite.com
data:
getDataFrom: <%start_date%>
to: <%end_date%>
do:
# USING ARGUMENT`age` OF CSV/FIELDSET ITERATOR IN A FORM
- find:
form: main
do:
- fields_set:
age: <%age%>
- submit
</code></pre>
</div>
<div id="arguments_reg" class="col s12">
<pre class="language-yaml">
<code class="language-yaml"># USING ARGUMENT `age` HEN POPULATING THE REGISTER
- register_set: Jane is <%age%> years old
</code></pre>
</div>
<div id="arguments_js" class="col s12">
<pre class="language-yaml">
<code class="language-yaml"># USING ARGUMENT `total` WHEN EXECUTING JS SNIPPET
- eval:
routine: js
body: '(function() {
var t = <%total%>;
var offset = [];
for(var i = 1; (i-1)*26 < t; i++) {
offset.push(i);
}
return offset.join(",");
})();'
</code></pre>
</div>
</div>
</div>
<p class="flow-text">
We will learn more about arguments usage in the corresponding <a href="meta-language-iterators-introduction.html">section</a>.
</p>
<div class="row">
<div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
<div class="pagination">
<a href="meta-language-runtime-entities-static-variables.html" class="btn goto teal z-depth-2">Next</a>
</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>